Is there a hook available that will allow me to add something in the middle of the discussion list. like something after the 5th Discussion or 5th Comment.
I would have to look to see about the discussion grid, but to put something after the 5th post, you could do something like this: if ('comments.php' == $Context->SelfUrl) { Function TweenPost(&$CommentGrid) $RowNumber = &$CommentGrid->DelegateParameters['RowNumber']; $Comment = &$CommentGrid->DelegateParameters['Comment'];
if ( 5 == $RowNumber ) { // close the existing CommentBody div, and open a new one that gets closed by the old div: $Comment->Body .= '</div><div class="TweenPost">' . $data; } $Context->AddToDelegate('CommentGrid', 'PreCommentOptionsRender', 'TweenPost'); } Edit: Changed TweenPost($$CommentGrid) to TweenPost(&$CommentGrid)
thats how i have done so far but i have to do that for every single delegate I'm using. I was hoping to call the function with the data, which will make my code lot smaller than it is right now
here are two functions that do 99% the same thing function DisplayMenuNugget(&$Menu) { global $NuggetObj; for ($i=0; $i < count($NuggetObj->Nugget); $i++) { if ($NuggetObj->Nugget[$i]['status']//check status && in_array($Menu->Context->Session->User->RoleID, $NuggetObj->Nugget[$i]['roles']) // check roles && in_array($Menu->Context->SelfUrl, $NuggetObj->Nugget[$i]['pages']) //check pages && $NuggetObj->Nugget[$i]['position'] == 'MENU') { $NuggetObj->Nugget[$i]['html'] = AllowPHP($NuggetObj->Nugget[$i]['html']); if(!$NuggetObj->Nugget[$i]['hideName']) $DisplayNuggetString = '<h2>'.$NuggetObj->Nugget[$i]['name'].'</h2>'; $DisplayNuggetString = '<div class="Nugget '.$NuggetObj->Nugget[$i]['position'].'">'.$DisplayNuggetString. $NuggetObj->Nugget[$i]['html'].'</div>'; echo $DisplayNuggetString; } }
What you have is completely fine. No excessive variables are made to go with each function so it doesn't run slower than it should. If your really desperate, you can add the '$NuggetObj' Object into the Context Object and have the render() function empty.
Comments
if ('comments.php' == $Context->SelfUrl) {
Function TweenPost(&$CommentGrid)
$RowNumber = &$CommentGrid->DelegateParameters['RowNumber'];
$Comment = &$CommentGrid->DelegateParameters['Comment'];
if ( 5 == $RowNumber ) {
// close the existing CommentBody div, and open a new one that gets closed by the old div:
$Comment->Body .= '</div><div class="TweenPost">' . $data;
}
$Context->AddToDelegate('CommentGrid', 'PreCommentOptionsRender', 'TweenPost');
}
Edit: Changed TweenPost($$CommentGrid) to TweenPost(&$CommentGrid)
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •Actually i want to display an ad after first comment ;-)
Thanks for your help guys
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •global $data;- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •but i have to do that for every single delegate I'm using. I was hoping to call the function with the data, which will make my code lot smaller than it is right now
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •function DisplayMenuNugget(&$Menu)
{
global $NuggetObj;
for ($i=0; $i < count($NuggetObj->Nugget); $i++)
{
if ($NuggetObj->Nugget[$i]['status']//check status
&& in_array($Menu->Context->Session->User->RoleID, $NuggetObj->Nugget[$i]['roles']) // check roles
&& in_array($Menu->Context->SelfUrl, $NuggetObj->Nugget[$i]['pages']) //check pages
&& $NuggetObj->Nugget[$i]['position'] == 'MENU')
{
$NuggetObj->Nugget[$i]['html'] = AllowPHP($NuggetObj->Nugget[$i]['html']);
if(!$NuggetObj->Nugget[$i]['hideName']) $DisplayNuggetString = '<h2>'.$NuggetObj->Nugget[$i]['name'].'</h2>';
$DisplayNuggetString = '<div class="Nugget '.$NuggetObj->Nugget[$i]['position'].'">'.$DisplayNuggetString. $NuggetObj->Nugget[$i]['html'].'</div>';
echo $DisplayNuggetString;
}
}
}
$Context->AddToDelegate('Menu', 'PreBodyRender', 'DisplayMenuNugget');
function DisplayBelowPanelNugget(&$Panel)
{
global $NuggetObj;
for ($i=0; $i < count($NuggetObj->Nugget); $i++)
{
if ($NuggetObj->Nugget[$i]['status']//check status
&& in_array($Panel->Context->Session->User->RoleID, $NuggetObj->Nugget[$i]['roles']) // check roles
&& in_array($Panel->Context->SelfUrl, $NuggetObj->Nugget[$i]['pages']) //check pages
&& $NuggetObj->Nugget[$i]['position'] == 'BELOW_PANEL')
{
$NuggetObj->Nugget[$i]['html'] = AllowPHP($NuggetObj->Nugget[$i]['html']);
if(!$NuggetObj->Nugget[$i]['hideName']) $DisplayNuggetString = '<h2>'.$NuggetObj->Nugget[$i]['name'].'</h2>';
$DisplayNuggetString = '<div class="Nugget '.$NuggetObj->Nugget[$i]['position'].'">'.$DisplayNuggetString. $NuggetObj->Nugget[$i]['html'].'</div>';
echo $DisplayNuggetString;
}
}
}
$Context->AddToDelegate('Panel', 'PostElementsRender', 'DisplayBelowPanelNugget');
I would like to just use one function, by passing appropriate parameters
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •