UBB.Dev
Posted By: Allusivekudos An if statement... - 10/14/2003 8:33 AM
It's me again

I'd like to add a query to my registered/unregistered header, but I only want it to run if it's on postlist.php and showflat.php..... Is there an if statement I can include with the query in the ubbt_registered.tmpl before the echo <<<UBBTPRINT to do that??

I'm thinking this is doable, but maybe not...
-peter
Posted By: Allusivekudos Re: An if statement... - 10/15/2003 5:01 AM
Anyone know if this is possible? Basically, I want to put the category / forum / post subject in the ubbt_registered.tmpl, but only do the queries if the pages are postlist or showflat...

Does that sound doable?
Posted By: Dave_L_dup1 Re: An if statement... - 10/15/2003 5:09 AM
I'm not clear on what you want to do. Could you provide an example, or examples, of what you want to display?
Posted By: Allusivekudos Re: An if statement... - 10/15/2003 5:25 AM
Yeah, I want the $CatName and $Title variables to display in the ubbt_registered menu bar basically....

I know I need to put a query in the template of ubbt_reg, something like this found in postlist....
Code
<br />// -------------------<br />// Grab the board info<br />   $Board_q = addslashes($Board);<br />   $query = "<br />      SELECT Bo_Title,Bo_CatName<br />      FROM   {$config['tbprefix']}Boards<br />      WHERE  Bo_Keyword = '$Board_q'<br />      $groupquery<br />   ";<br />   $sth = $dbh -> do_query($query);<br />   $rows = $dbh -> fetch_array($sth);<br />   list($Title,$CatName) = $rows;<br />   $dbh -> finish_sth($rows);<br />   if (!$Title) {<br />      $html -> not_right($ubbt_lang['BAD_GROUP'],$Cat);<br />   }<br />



So, basically, I need that query to be in the template, but only run if the page is postlist or showflat... Maybe there is a simpler way...

The point is that is that I'm building a menu and will have the Site Name : Forum Name : Post Title in the menu, where appropriate. Hope that made sense...

-peter
Posted By: JustDave Re: An if statement... - 10/15/2003 5:26 AM
You should place your query code in the postlist/showflat php files and use an if statement to see if the use is registered/logged in before doing the queries:

if ($user['U_Number'] > 1) {
// do query
}


Store the results in a variable and display the variable in your ubbt_registered.tmpl file.
Posted By: Allusivekudos Re: An if statement... - 10/15/2003 5:37 AM
Dave -

I added the following code below the similar query in postlist....
Code
<br />if ($user['U_Number'] > 1) {<br />// -------------------<br />// Grab the board info   <br />$Board_q = addslashes($Board);   <br />       $query = "      <br />    SELECT<br />         Bo_Title,Bo_CatName      <br />       FROM   {$config['tbprefix']}Boards      <br />       WHERE  Bo_Keyword = '$Board_q'      <br />           $groupquery   ";   <br />           $sth = $dbh -> do_query($query);   <br />           $rows = $dbh -> fetch_array($sth);   <br />           list($TitleMenu,$CatNameMenu) = $rows;   <br />             $dbh -> finish_sth($rows);  <br />          if (!$TitleMenu) {      <br />            $html -> not_right($ubbt_lang['BAD_GROUP'],$Cat);   }<br />                        }<br />




And then added $CatNameMenu and $TitleMenu to the ubbt_registered.tmpl, but it's still not showing.... ? Did I do something wrong or misinterpret your instructions?

thanks for working with me!

-peter
Posted By: JustDave Re: An if statement... - 10/15/2003 6:59 AM
Any errors? Perhaps the query isn't returning any results?

You could place this in to see:

echo "$TitleMenu,$CatNameMenu"; exit;


right after

$dbh -> finish_sth($rows);


and see if there are any results.
Posted By: Allusivekudos Re: An if statement... - 10/15/2003 7:04 AM
Yep, that spits out two correct results.
Posted By: Allusivekudos Re: An if statement... - 10/15/2003 7:27 AM
This is totally weird. I actually followed what you had me do, but it just doesn't show anything...No errors either..

Posted By: JustDave Re: An if statement... - 10/15/2003 3:27 PM
It's probably because the variables need to be made global or need to be pulled into the function sending the ubbt_registered template.
Posted By: Allusivekudos Re: An if statement... - 10/15/2003 8:06 PM
Can you give me an idea how to do that please?

Posted By: JustDave Re: An if statement... - 10/17/2003 5:00 AM
in the main include script set the variables at the begining of the script. Then in the send_header function add the variables to the 'global' call. Then they should be available in the ubbt_registerednav template.
Posted By: Allusivekudos Re: An if statement... - 10/17/2003 5:41 AM
Works great! Thank you!
Posted By: Allusivekudos Re: An if statement... - 10/17/2003 6:43 AM
Whoa! I tinkered with adding a couple things.... Is there any danger in adding some more variables to this? Like anything I should know?

-peter
Posted By: Allusivekudos Re: An if statement... - 10/17/2003 8:54 AM
Dave - or anyone - another question -


Do you know how I can add the "post" link from postlist to the global variables.... I added $newpoststart and $newpoststop to the send header function, but it's not working... I did get the reply link to do this from showflat in the nav menu though...so it's gotta be possible..


-peter
Posted By: Allusivekudos Re: An if statement... - 10/19/2003 9:25 AM
Okay, so in postlist, here's where the whole newpoststart and newpoststop stuff are defined....

Code
 // --------------------------------------------------------------------- <br />// We need to check and see if they have write privileges for this forum <br />   $gsize = sizeof($Grouparray); <br />   for ($i=0; $i <$gsize; $i++) { <br />      if (strstr($CanWrite,"-$Grouparray[$i]-") ) { <br />         $makepost = "yes"; <br />         break; <br />      } <br />   } <br />   if ($makepost == "yes") { <br />      $newpoststart = "<a href=\"{$config['phpurl']}/newpost.php..;sb=$sb&amp;o=$o\">"; <br />      $postoption = "newpost.gif"; <br />      $newpoststop = "</a>"; <br />   } <br />   else { <br />      $postoption = "greynewpost.gif"; <br />   } 


Does anyone know what all I need to put in the global header call to get that bit to work? The goal again, is to make a link that shows in the header for posting...
Posted By: Allusivekudos Re: An if statement... - 10/20/2003 8:12 AM
Just in case it's not clear what I'm doing, if you can, check out my test board:

test board

Guest users will still see what I'm trying to do... When you click a forum, the ideal thing is that that post link will work, just like if you go into a thread the reply link does...

-peter
Posted By: Allusivekudos Re: An if statement... - 10/26/2003 7:44 AM
Does anyone, anyone at all know how to do this?

All I want to do is have the post link, from postlist.php work from the header in ubb_registered/ubb_unregistered.tmpl's.


-peter
Posted By: Allusivekudos Re: An if statement... - 10/26/2003 8:06 AM
WOOHOO! trial and error baby!! I gots it!

© UBB.Developers