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.
Changing How Categories Look At The Panel
I have been looking into how to do some slight modifications to the way Categories are listed, basically I want to remove some Categories from being listed. Since I don't think it's a themes modification, I have been looking into applications to no avail.
I am not really sure if I should be looking under Modules or Controllers as I don't think I have found anything relevant. If anybody can point me the direction, ie the file to look at, it would be much appreciated!
Anyway, just another question. When you do a modification to an Application, do you usually copy the files out into a different folder as a new application? I am just wondering what is the best practice as I don't want anything I modified right now to be rewritten in the future upgrades, but I don't think Applications work like the way Themes work. Please advise.
I am not really sure if I should be looking under Modules or Controllers as I don't think I have found anything relevant. If anybody can point me the direction, ie the file to look at, it would be much appreciated!
Anyway, just another question. When you do a modification to an Application, do you usually copy the files out into a different folder as a new application? I am just wondering what is the best practice as I don't want anything I modified right now to be rewritten in the future upgrades, but I don't think Applications work like the way Themes work. Please advise.
0
Comments
Now I am just wondering if Applications would be like Themes, where you can have a different copy of the file that get executed, without editing the original file and without copying the entire folder.
@jjsee, this is not the best solution. In fact, it's probably really crap.
Hooks are your friend.
Hooks are, IMO, the best way to modify the output of the application without changing the application itself (I also don't like changing the app). And no, I don't think creating a copy of the application under a new application will work as you expect.
Read the hooks link, also check out what plugins can do, create your hooks.php file, and then what you want to do is create a public function called Base_Render_Before. I believe this will target all of your controllers (every page).
This is the categories module
$Sender->Assets['Panel']['CategoriesModule']
Now, by this point in execution, the Categories module has been converted ToString and is no longer an object.
How you are going to manipulate that string to remove specific categories will be a pain; sorry, I can't help you there. To remove the CategoriesModule completely, simply unset() that value.
You might be able to put the string into an XML parser and then searching for specific nodes to remove.
I wouldn't have a clue how to do that and keep the files seperate
To change the way Categories are listed at the side bar, copy applications/vanilla/views/modules/categories.php into /themes/views/modules
You will see a foreach statement in the file:
foreach ($this->_CategoryData->Result() as $Category) {
Immediately after this, add this:
if ($Category->CategoryID != 1) {
Whereby 1 is the category id number that I would like to exclude. Also, immediately before the closing curly bracket } for the foreach loop, add another closing curly bracket } to close your new if statement.
If you would like to exclude multiple Categories, you can do it with a few ANDs like this:
if (($Category->CategoryID != 1) && ($Category->CategoryID != 5)){
You can play around with this to create a second or third set of listing on the same side menu, with the Categories that you previously excluded by reversing the conditions of the if statement, which is actually what I am doing.
It might be easier to maintain if you followed this line:
foreach ($this->_CategoryData->Result() as $Category) {
with something more like this: That way if you want to exclude more than one category, just keep adding CategoryIDs to the array.
Vanilla Forums COO [GitHub, Twitter, About.me]
I don't remember if my modifications on discussions.php is relevant or not.
This is a sample of my discussions.php (but I think I broke something while changing something just now, so proceed with caution)
foreach ($this->DiscussionData->Result() as $Discussion) {
if (($Discussion->CategoryID != 1) || ($this->CategoryID == 1)) {
$Alt = $Alt == ' Alt' ? '' : ' Alt';
WriteDiscussion($Discussion, $this, $Session, $Alt);
}
}
However, I thought it was working excellent, until I realize that I have to take into consideration other ways of listing, ie My Discussions, My Bookmarks, My Drafts etc, or the filtered discussion list will not display for those.
Still trying to find out how I could track how are users viewing the list. Pointers are appreciated.