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.
Conflict with David + Discussion Tags/Filters
So I was having some weird issue with Discussion Tags and Filters. Clicking on the Tag/Filter, I got all discussions, not just the tagged or filtered discussions. I stripped my forum and started re-adding extensions one by one. I discovered the problem was with the David extension.
The extensions runs fine if you don't change anything. But I wanted stickies from certain categories to show on the index page, so I made the suggested tweak:
The tweak was to remove that commented $SB->AddWhere. The stickies did what they were suppose to, but it messed with Discussion Tags/ Filters.
I would like to keep the stickies the way they were. Is there a way to fix David such that it won't cause issues with Discussion Tags/Filters?
The extensions runs fine if you don't change anything. But I wanted stickies from certain categories to show on the index page, so I made the suggested tweak:
global $CategoryToShow;
$CategoryToShow = '12'; // change this to also show this Category Sticky
if ( ($Context->SelfUrl == "index.php") && isset($Head) )
{
// this allows you to see the Sticky on the Category page but not on the index page
if ( ForceIncomingString('CategoryID', '') < '1' )
{
function Sticky_HideFromDiscussions(&$DiscussionManager)
{
global $CategoryToShow;
// this function adjusts the Discussion count
$SB = &$DiscussionManager->DelegateParameters['SqlBuilder'];
foreach ( array('0') as $CurrentBlock )
{
$SB->AddWhere('t', 'Sticky', '', 0, '=', 'and');
// $SB->AddWhere('t', 'CategoryID', '', $CategoryToShow, '=', 'or');
}
}
$Context->AddToDelegate('DiscussionManager', 'PostGetDiscussionBuilder', 'Sticky_HideFromDiscussions');
$Context->AddToDelegate('DiscussionManager', 'PreGetDiscussionCount', 'Sticky_HideFromDiscussions');
}
}
The tweak was to remove that commented $SB->AddWhere. The stickies did what they were suppose to, but it messed with Discussion Tags/ Filters.
I would like to keep the stickies the way they were. Is there a way to fix David such that it won't cause issues with Discussion Tags/Filters?
0
This discussion has been closed.
Comments
$TagFilter = ForceIncomingInt("TagFilter", 0); // don't conflict with DiscussionTags add-on
Then change the "if statement" to the following to only execute my script if there is no DiscussionTags filter:
if ( ($Context->SelfUrl == "index.php") && isset($Head) && $TagFilter == 0)
...
OK, so looking at your code, and then the code from DiscussionTags and DiscussionFilters, I added/changed the following:
$TagFilter = ForceIncomingInt("TagFilter", 0); $View = ForceIncomingString("View", ""); if ( ($Context->SelfUrl == "index.php") && isset($Head) && $TagFilter == 0 && $View == "")
That seems to take care of Discussion Filters. Now everything seems to be working the way it should. Thanks again!
$CommentID = ForceIncomingInt("CommentID", 0);
and then:
&& $CommentID == 0
But there has to be a better way to fix this. The common thread seems to be that these extensions filter the discussion list by appending "index.php" with "?Something=something".
Is there some way to modify the if statement, such that it returns false if the current url is "index.php?Anything"? Is there a better way to reference the discussion list other than ($Context->SelfUrl == "index.php")?
$url = GetRequestUri(); // parse this to see if there is a "?" $xxx = strpos($url,'index.php?'); if ( ($Context->SelfUrl == "index.php") && isset($Head) && $xxx == 0)
That should handle it for any url that has "index.php?" in it.
Edit: Now that I've looked at this some more, you should change the $xxx line to be:
$xxx = strpos($url,'?');
We only need to look for the "?"