Author |
Message |
jane65
Regular


Joined: Feb 24, 2009
Posts: 81
Location: UK
|
Posted:
Fri Jan 11, 2013 12:11 pm |
|
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
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&pa=showpage&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&pa=showpage&pid='.$XXpid.'" title="">'.$XXtitle2.'</a></li>';
}
$nukeNAV .= '
</ul>
</li>';
}else{
$nukeNAV .= '</li>';
}
}
if (is_user($user)) $nukeNAV .= '
<li><a href="modules.php?name=Content&pa=add_page" title="">Add Page</a></li>';
$nukeNAV .= '
</ul>
</li>';
}else{
$nukeNAV .= '</li>';
}
}
|
|
|
|
|
 |
Guardian2003
Site Admin

Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam
|
Posted:
Fri Jan 11, 2013 6:02 pm |
|
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? |
|
|
|
 |
jane65

|
Posted:
Fri Jan 11, 2013 7:30 pm |
|
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  |
|
|
|
 |
neralex
Site Admin

Joined: Aug 22, 2007
Posts: 1775
|
Posted:
Sat Jan 12, 2013 11:01 am |
|
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&pa=showpage&pid=' . $contid . '" title="">' . $conttitle . '</a>';
|
|
_________________ Only registered users can see links on this board! Get registered or login! |
|
|
 |
jane65

|
Posted:
Sun Jan 13, 2013 3:59 am |
|
Hi neralex, thank you for helping me with this, its very much appreciated
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

|
Posted:
Sun Jan 13, 2013 4:23 am |
|
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

|
Posted:
Sun Jan 13, 2013 4:30 am |
|
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
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&pa=showpage&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&pa=showpage&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&pa=showpage&pid='.$XXpid.'" title="">'.$XXtitle2.'</a></li>';
}
$nukeNAV .= '
</ul>
</li>';
}else{
$nukeNAV .= '</li>';
}
}
if (is_user($user)) $nukeNAV .= '
<li><a href="modules.php?name=Content&pa=add_page" title="">Add Page</a></li>';
$nukeNAV .= '
</ul>
</li>';
}else{
$nukeNAV .= '</li>';
}
}
|
|
|
|
|
 |
jane65

|
Posted:
Mon Jan 14, 2013 7:50 am |
|
Just to thank you again for your help neralex. I've only just seen the code that you posted, I didn't see it there before I posted my last post. |
|
|
|
 |
|