Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Mark Unread
This discussion has been closed.
Comments
My problem is about dictionary definitions.
if( $Context->SelfUrl == 'index.php' ) { function DiscussionGrid_DiscussionPages($DiscussionGrid) { $Discussion = &$DiscussionGrid->DelegateParameters['Discussion']; $DiscussionList = &$DiscussionGrid->DelegateParameters['DiscussionList']; $DiscussionList = str_replace($Discussion->Name.'</a>', $Discussion->Name .'</a>'. ($Discussion->CountComments >20 ?' <i>Hot!</i>':''), $DiscussionList); }
I'd like to add two definitions, one for the number of comments making a discussion hot (above 20 in our case) and one for the Hot! text. But I don't know how :B
Any idea?
//put this at the beginning of default.php of that extension, or just before the code you posted $Context->SetDefinition( 'HotCommentsSetting', '20' ); $Context->SetDefinition( 'TextHot', 'Hot!' ); //and alter the code you posted here to: if( $Context->SelfUrl == 'index.php' ) { function DiscussionGrid_DiscussionPages($DiscussionGrid) { $Discussion = &$DiscussionGrid->DelegateParameters['Discussion']; $DiscussionList = &$DiscussionGrid->DelegateParameters['DiscussionList']; $DiscussionList = str_replace($Discussion->Name.'</a>', $Discussion->Name .'</a>'. ($Discussion->CountComments >$Context->GetDefinition('HotCommentsSetting') ?' <i>$Context->GetDefinition('TextHot')</i>':''), $DiscussionList); }
I just would like to say that using dictionary definitions for add-on settings is not the cleanest way, but I know that some add-ons use this.
There is another way how to do it, but this would work
I've seen you've released an extension for localisation purposes but I didn't understand everthing, what would you suggest for the cleanest way ?
well, the second issue (clean way) I meant about only for settings, and number of comments making discussion Hot is rather a setting than a language data.
For example there is a FeedReader extension reading RSS and displaying the feed in Control Panel on the left, but the RSS URL and some other settings is saved in dictionary definitions. I think it has been only temporary solution, because I can see there is some draft of settings panel for that.
So I only think that in dictionary definitions there should be only language data :-)
About the clean way I'm not sure, because I'm still kind of newbie here and I haven't yet used it much, but I guess this should work:
AddConfigurationSetting( $Context, 'HOT_COMMENTS_NUMBER', 20 );
somewhere at the beginning of default.php of the add-on
and you can read the settings any time later by:
$Context->Configuration['HOT_COMMENTS_NUMBER']
so the code above would look like this:
//put this at the beginning of default.php of that extension, or just before the code you posted AddConfigurationSetting( $Context, 'HOT_COMMENTS_NUMBER', 20 ); $Context->SetDefinition( 'TextHot', 'Hot!' ); //and alter the code you posted here to: if( $Context->SelfUrl == 'index.php' ) { function DiscussionGrid_DiscussionPages($DiscussionGrid) { $Discussion = &$DiscussionGrid->DelegateParameters['Discussion']; $DiscussionList = &$DiscussionGrid->DelegateParameters['DiscussionList']; $DiscussionList = str_replace($Discussion->Name.'</a>', $Discussion->Name .'</a>'. ($Discussion->CountComments > $Context->Configuration['HOT_COMMENTS_NUMBER'] ?' <i>$Context->GetDefinition('TextHot')</i>':''), $DiscussionList); }
Then anybody can change the number in conf/settings.php and doesn't have to define language definition to change it
I've somewhat managed to write values like that in the configuration file for my Stuff Displayer extension. I think I'll try to do the same here. It will be more user-friendly to have administrator settings for specifying the "Hot" value and the text (or the image). Thanks for the input.