Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Themes
Author Message
jane65
Regular
Regular



Joined: Feb 24, 2009
Posts: 81
Location: UK

PostPosted: Fri Jan 11, 2013 12:11 pm Reply with quote

Hi,
I am seeking help with modifying this code that is already modified for the navigation to display the pages of an individual category in the Content module, the code is situated in the includes/jquery/nukenav.php file.

I need to make the navigation menu for this particular content module category switch to display the menu of another content module category instead when the User Logs in to the system. Basically the intention is for the Anonymous User to see a different Nav menu for this category to what the Logged in User sees.

I hope this makes sense, I have tried to change it but I don't know enough code to be able to do it. Thanks in advance for any help Smile


Code:
if (is_active('Content')) {

   $nukeNAV .= '
<li><a href="/modules.php?name=Content&pa=showpage&pid=23" title="">Animals</a>';
   $NAVresult = $db->sql_query('SELECT * FROM '.$prefix.'_pages pages WHERE active=\'1\' AND cid=1');
   $NAVnumrows = $db->sql_numrows($NAVresult);
      if ($NAVnumrows > 0) {
      $nukeNAV .= '
     <ul>';
      while ($XXrow = $db->sql_fetchrow($NAVresult)) {
      $XXpid = $XXrow['pid'];
      $XXtitle = $XXrow['title'];
      // display cat
      $nukeNAV .= '
   <li><a href="/modules.php?name=Content&amp;pa=showpage&amp;pid='.$XXpid.'" title="">'.$XXtitle.'</a>';
   // content for cat
   $NAVresult2 = $db->sql_query('SELECT * FROM '.$prefix.'_pages WHERE active=\'1\' AND pid=\''.$XXpid.'\'');
       if ($NAVnumrows2 > 0) {
      $nukeNAV .= '
     <ul>';
      while ($XXrow2 = $db->sql_fetchrow($NAVresult2)) {
      $XXpid = $XXrow2['pid'];
      $XXtitle2 = $XXrow2['title'];
      $nukeNAV .= '
   <li><a href="modules.php?name=Content&amp;pa=showpage&amp;pid='.$XXpid.'" title="">'.$XXtitle2.'</a></li>';
      }
      $nukeNAV .= '
     </ul>
   </li>';
      }else{
       $nukeNAV .= '</li>';
     }
}
   if (is_user($user)) $nukeNAV .= '
 <li><a href="modules.php?name=Content&amp;pa=add_page" title="">Add Page</a></li>';
   $nukeNAV .= '
  </ul>
</li>';
   }else{
   $nukeNAV .= '</li>';
   }
}
 
View user's profile Send private message
Guardian2003
Site Admin



Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam

PostPosted: Fri Jan 11, 2013 6:02 pm Reply with quote

I'm not sure I understand what you are trying to do.
You want the menu to work as normal for a registered user but want to hide a specific Content category if the user is anonymous?
 
View user's profile Send private message Send e-mail
jane65







PostPosted: Fri Jan 11, 2013 7:30 pm Reply with quote

Thanks for replying. I want the menu to work as normal, but need the specific Content category to switch to being a different Content category when a User logs in. For instance, the Anonymous User sees the content category 'Animals' in the nav bar before logging in, and after login sees a different content category in its place, ie: Accessories, instead of Animals. Basically the category Animals would totally disappear from the Navigation bar after log in and be replaced by another content category.

I hope this makes better sense and thank you for your help Smile
 
neralex
Site Admin



Joined: Aug 22, 2007
Posts: 1772

PostPosted: Sat Jan 12, 2013 11:01 am Reply with quote

search:

Code:
   $nukeNAV .= '

<li><a href="/modules.php?name=Content&pa=showpage&pid=23" title="">Animals</a>';


replace it with:

Code:
   if (is_user($user)) {

      $contid = '22';
      $conttitle = 'Accessories';
   } else {
      $contid = '23';
      $conttitle = 'Animals';
   }
   $nukeNAV .= '<li><a href="/modules.php?name=Content&amp;pa=showpage&amp;pid=' . $contid . '" title="">' . $conttitle . '</a>';

_________________
Github: RavenNuke 
View user's profile Send private message
jane65







PostPosted: Sun Jan 13, 2013 3:59 am Reply with quote

Hi neralex, thank you for helping me with this, its very much appreciated Smile

The code that you gave me works great in changing the actual category title on the navigation bar after the user logs in, but the Animals category link has a drop down navigation list of links to its specific content pages, and although the title changes to Accessories, the system still displays a drop down list linked to the Animals category pages instead of the Accessories category pages.

I think it may be these two lines of code need modifying some way as the CID=1 links to the system displaying the content pages of the Animals category, whereas the Accessories Category is CID=4, so somehow I need to tell the system to switch from CID=1 to CID=4 after the User logs in.

Code:
$NAVresult = $db->sql_query('SELECT * FROM '.$prefix.'_pages pages WHERE active=\'1\' AND cid=1');


Code:
$NAVresult2 = $db->sql_query('SELECT * FROM '.$prefix.'_pages WHERE active=\'1\' AND pid=\''.$XXpid.'\'');
 
neralex







PostPosted: Sun Jan 13, 2013 4:23 am Reply with quote

search:

Code:
   if (is_user($user)) {

      $contid = '22';
      $conttitle = 'Accessories';
   } else {
      $contid = '23';
      $conttitle = 'Animals';
   }


add a new variable with the cid and replace it with:

Code:
   if (is_user($user)) {

      $contid = '22';
      $conttitle = 'Accessories';
      $contcid = '4';
   } else {
      $contid = '23';
      $conttitle = 'Animals';
      $contcid = '1';
   }


search:

Code:
$NAVresult = $db->sql_query('SELECT * FROM '.$prefix.'_pages pages WHERE active=\'1\' AND cid=1');


use here the new variable $contcid instead of your hard coded cid '1' and replace it with:

Code:
$NAVresult = $db->sql_query('SELECT * FROM `' . $prefix . '_pages` pages WHERE `active` = \'1\' AND `cid` = \'' . $contcid . '\'');
 
jane65







PostPosted: Sun Jan 13, 2013 4:30 am Reply with quote

Its ok, I've just managed to work it out, I added $XXcid='1'; & $XXcid="4"; to the code you gave me and changed the first $navresult line in the code. I've pasted the whole code again below just in case someone else wants to do this. Thank you very much for your help Smile


Code:
if (is_active('Content')) {

   if (is_user($user)) {
      $contid = '25';
      $conttitle = 'Accessories';
      $XXcid = '4';
   } else {
      $contid = '23';
      $conttitle = 'Animals';
      $XXcid = '1';
  }
   $nukeNAV .= '<li><a href="/modules.php?name=Content&amp;pa=showpage&amp;pid=' . $contid . '" title="">' . $conttitle . '</a>';
  $NAVresult = $db->sql_query('SELECT * FROM '.$prefix.'_pages pages WHERE active=\'1\' AND cid=\''.$XXcid.'\'');
   $NAVnumrows = $db->sql_numrows($NAVresult);
      if ($NAVnumrows > 0) {
      $nukeNAV .= '
     <ul>';
      while ($XXrow = $db->sql_fetchrow($NAVresult)) {
      $XXpid = $XXrow['pid'];
      $XXtitle = $XXrow['title'];
      // display cat
      $nukeNAV .= '
   <li><a href="/modules.php?name=Content&amp;pa=showpage&amp;pid='.$XXpid.'" title="">'.$XXtitle.'</a>';
   // content for cat
   $NAVresult2 = $db->sql_query('SELECT * FROM '.$prefix.'_pages WHERE active=\'1\' AND pid=\''.$XXpid.'\'');
       if ($NAVnumrows2 > 0) {
      $nukeNAV .= '
     <ul>';
      while ($XXrow2 = $db->sql_fetchrow($NAVresult2)) {
      $XXpid = $XXrow2['pid'];
      $XXtitle2 = $XXrow2['title'];
      $nukeNAV .= '
   <li><a href="modules.php?name=Content&amp;pa=showpage&amp;pid='.$XXpid.'" title="">'.$XXtitle2.'</a></li>';
      }
      $nukeNAV .= '
     </ul>
   </li>';
      }else{
       $nukeNAV .= '</li>';
     }
}
   if (is_user($user)) $nukeNAV .= '
  <li><a href="modules.php?name=Content&amp;pa=add_page" title="">Add Page</a></li>';
   $nukeNAV .= '
  </ul>
</li>';
   }else{
   $nukeNAV .= '</li>';
   }
}
 
jane65







PostPosted: Mon Jan 14, 2013 7:50 am Reply with quote

Just to thank you again for your help neralex. Smile I've only just seen the code that you posted, I didn't see it there before I posted my last post.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Themes

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©