Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Is it okay to import 'controllers' into custom theme just like 'views'?

edited March 2012 in Vanilla 2.0 - 2.8

The documentation says that all application 'views' can be moved to a custom theme:

Master Views: These represent everything that wraps the main content of every page. If all you want to do is add a menu or banner above Vanilla, this is the only file you will need to alter. To do so, copy the default master view from /applications/dashboard/views/default.master.php to /themes/your_theme_name/views/default.master.php and edit it there.

Views: These represent all of the content in each page. Every application has a "views" folder that contains all of the html for every page. So, for example, if you wanted to edit the html for the discussion list, you could copy the views from /applications/vanilla/views/discussions to /themes/your_theme_name/views/discussions and edit them there.

Does this apply to the 'controllers' as well? For example, can I move /applications/dashboard/controllers/class.entrycontroller.php to /themes/[custom theme]/controllers/class.entrycontroller.php ? Is it going to work?

Hope to see someone knowledgeable clarify on this. Thanks.

Best Answers

  • x00x00 MVP
    Answer ✓

    no, definitely not. This is bound to end in tears. This why you extend with

    even with views, there is some risk of redundancy, and errors when you update becuase it could be referencing an object that is no longer used. However, generally it is ok if you are aware. This becuase view are supposed to be logic light. It should only to be to do with the direct display (however the line is quite grey, and it is not always possible).

    grep is your friend.

  • x00x00 MVP
    Answer ✓

    ok had a look at the voting plugin it is there

    T('Follows')

    look up locales in the documentation.

    grep is your friend.

  • x00x00 MVP
    edited March 2012 Answer ✓

    in /locales/YourLocale/definitions.php

    <?php if (!defined('APPLICATION')) exit();
    $LocaleInfo['YourLocale'] = array (
      'Locale' => 'YourLocale',
      'Name' => 'Your Locale',
      'Description' => 'Your Locale',
      'Version' => '1.0.1b',
      'Author' => 'Your Name',
      'AuthorEmail' => 'your@email.com',
      'AuthorUrl' => 'http://vanillaforums.org/profile/yourname'
    );
    $Definition['Follows']='Stalkers';
    

    then follow the instruction on how to enable. It si also a good idea to copy the definitions from forumtest/applications/dashboard/locale/en-CA/definitions.php to your locale.

    grep is your friend.

  • peregrineperegrine MVP
    Answer ✓

    Clear Documentation thanks.

    An alternate way that was pointed out to me by @Lincoln.

    http://vanillaforums.org/discussion/comment/155751#Comment_155751

    If you are only changing a few definintions, you could modify the locale.php in the conf directory and just add these two lines. Don't know which is the preferred way.

    # $Definition['Bookmark'] = 'Follow Discussion';
    # $Definition['Unbookmark'] = 'Unfollow Discussion';
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • peregrineperegrine MVP
    Answer ✓

    I was just going to write that "It probably will get overwritten in an upgrade"
    I just make a copy of it and call it "updated-locale.ph" leaving off the letter in the extension, so it doesn't fire off or interfere with the main one.
    Then I will go through the directories and look for update and diff the changes, after an upgrade.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • LincLinc Admin
    Answer ✓

    conf/locale.php is not distributed with Vanilla, so no, it will not get overridden.

  • LincLinc Admin
    Answer ✓

    Missed this, sorry. You can safely ignore the conf/locale.php file when upgrading. I'm not sure why that's even in core.

«1

Answers

  • x00x00 MVP
    Answer ✓

    no, definitely not. This is bound to end in tears. This why you extend with

    even with views, there is some risk of redundancy, and errors when you update becuase it could be referencing an object that is no longer used. However, generally it is ok if you are aware. This becuase view are supposed to be logic light. It should only to be to do with the direct display (however the line is quite grey, and it is not always possible).

    grep is your friend.

  • edited March 2012

    Oh, okay. Here's the thing @x00 — I am trying to change the title attribute of the 'Follows' box added by ('Voting' plugin) from "Bookmark" and "Unbookmark" to "Follow Discussion" and "Unfollow Discussion" — the thing is, it's being changed by some JavaScript or Ajax function (aside from the PHP in a view file - for changes in real-time without browser refresh), which I am unable to find even using grep.

    Imgur

    Can you try to help me with that?

  • x00x00 MVP
    edited March 2012

    -

    grep is your friend.

  • I never really had those in theme. it is definitely not javascript, on this site. have you tried setting the 'Follows' locale definition?

    No. I don't know what that is. Can you try to be more clear? (locale definition? Where should I look for it?)

  • x00x00 MVP
    Answer ✓

    ok had a look at the voting plugin it is there

    T('Follows')

    look up locales in the documentation.

    grep is your friend.

  • @x00 : Yeah, looking right at it. I don't know how to code in PHP, but I hope my common sense helps, as it has so far. :)

  • edited March 2012

    @x00 : The documentation doesn't make sense to me at all — it isn't clear. Can you please explain to me in simple words (& if possible precisely) as to what I should do?

    If you can't do the above (i.e. if what I asked is not easy to explain) I plan to follow this (but I hate to have to use yet another plugin on my site). Should I?

    Using the Baseline Locale Addon

    There is a Baseline Locale addon available in our addons repository that you can use to build your custom locale definitions. To Get Started:

    1. download the Baseline Locale addon
    2. Uncompress the archive, and rename the folder to a phrase with only alphanumeric characters (no spaces, dashes, etc). Example: "danish".
    3. Open the definitions.php file, and update it with your information. Be sure to replace the 'LocaleKey' value (it is "Baseline" by default) with the same name you chose for the containing folder.
    4. Open the captured.php and captured_admin.php files and replace the English definitions with the appropriate values for your language.

    I am reading the documentation all over again though... just in case it starts to make sense all of a sudden. :)

  • x00x00 MVP
    edited March 2012 Answer ✓

    in /locales/YourLocale/definitions.php

    <?php if (!defined('APPLICATION')) exit();
    $LocaleInfo['YourLocale'] = array (
      'Locale' => 'YourLocale',
      'Name' => 'Your Locale',
      'Description' => 'Your Locale',
      'Version' => '1.0.1b',
      'Author' => 'Your Name',
      'AuthorEmail' => 'your@email.com',
      'AuthorUrl' => 'http://vanillaforums.org/profile/yourname'
    );
    $Definition['Follows']='Stalkers';
    

    then follow the instruction on how to enable. It si also a good idea to copy the definitions from forumtest/applications/dashboard/locale/en-CA/definitions.php to your locale.

    grep is your friend.

  • edited March 2012

    @x00 : Thanks a lot. The documentation is clear as well, I should have read it more carefully and slowly.

    Let me see if I can pull it off — if I do, there'll be a very clear 'how-to' explanation here shortly for everyone else :)

    And... It would be great if someone (who can) can add this to Vanillaforums.org's custom.css file:

    pre, code {
    white-space: pre-wrap;
    }
    
  • edited March 2012

    I pulled it off! Here's the how-to for everyone as I promised...

    [1] Go to /locales directory right inside your Vanilla forum's root directory.

    [2] In /locales create a directory /MyLocaleChanges (name's your choice)

    [3] Into /MyLocaleChanges upload a file named 'definitions.php' with the following content:

    <? php if (!defined('APPLICATION')) exit();
    
    $LocaleInfo['skeleton'] = array( // make sure the key of this array is the same as its folder name.
       'Locale'       => 'en-CA',
       'Name'         => 'Skeleton Locale',
       'Description'  => 'This is a skeleton of a locale pack. If you want to create your own locale pack copy and rename this folder into your locales folder.',
       'Version'      => '2.0.1',
       'Author'       => "Your Name",
       'AuthorEmail'  => 'Your Email',
       'AuthorUrl'    => 'http://your.domain.com',
       'License'      => 'Your choice of license'
    );
    
    $Definition['Bookmark'] = 'Follow Discussion';
    $Definition['Unbookmark'] = 'Unfollow Discussion';
    

    As you can see, the last two lines were added my me. Now, "Bookmark" gets translated to "Follow Discussion", and so on.

    [4] Now go to Dashboard > Locales and enable 'My Locale Changes.'

    [5] That's all, but the definitions in captured.php file in Baseline Locale Addon will be a good reference when you want to confirm if you are replacing the right term.

    Hope I'm clear enough. :) Special thanks to @x00 !

  • peregrineperegrine MVP
    Answer ✓

    Clear Documentation thanks.

    An alternate way that was pointed out to me by @Lincoln.

    http://vanillaforums.org/discussion/comment/155751#Comment_155751

    If you are only changing a few definintions, you could modify the locale.php in the conf directory and just add these two lines. Don't know which is the preferred way.

    # $Definition['Bookmark'] = 'Follow Discussion';
    # $Definition['Unbookmark'] = 'Unfollow Discussion';
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Thanks @peregrine that'll help. But do you know if the custom definitions in locale.php get overridden when Vanilla is updated?

  • peregrineperegrine MVP
    Answer ✓

    I was just going to write that "It probably will get overwritten in an upgrade"
    I just make a copy of it and call it "updated-locale.ph" leaving off the letter in the extension, so it doesn't fire off or interfere with the main one.
    Then I will go through the directories and look for update and diff the changes, after an upgrade.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • edited March 2012

    @peregrine : Nice suggestion. It's always good to have a choice. :) Thanks!

    (Well, as you can see, this question has hell a lot of answers!)

  • peregrineperegrine MVP
    edited March 2012

    also, if the definitions don't seem to take effect after changes to locales

    I believe deleting the /cache/locale_map.ini file will fix the problem.

    I am just a novice at this, and I would certainly defer to the suggestions by the experts.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Yep. I read that here just before wrote.

  • LincLinc Admin
    Answer ✓

    conf/locale.php is not distributed with Vanilla, so no, it will not get overridden.

  • @Lincoln : Thanks for the tip!

    @peregrine : Just wanted to let you know (see Lincoln's comment).

  • peregrineperegrine MVP
    edited March 2012

    @Lincoln replied

    conf/locale.php is not distributed with Vanilla, so no, it will not get overridden.

    If I look at vanilla-core-2-0-18-3.zip, I can see conf/locale.php inside. Wouldn't this mean it would be overwritten or am I missing something?

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Sign In or Register to comment.