Welcome, Guest. Please login or register.
March 20, 2010, 11:28:34 PM

Login with username, password and session length
Search:     Advanced search
Wollen Sie dem Website Baker Team beitreten?
Nähere Informationen finden Sie unter hier und auf unserer neuen Webseite .
110559 Posts in 15966 Topics by 9310 Members
Latest Member: stevenris10
* Home Help Search Login Register
+  WebsiteBaker Community Forum
|-+  English
| |-+  Help & Support (Moderators: Argos, BerndJM)
| | |-+  Navigation << previous | up | next >>
Pages: [1] Go Down Print
Author Topic: Navigation << previous | up | next >>  (Read 3346 times)
Kralle

Offline Offline

Posts: 14


WWW
« on: September 14, 2006, 01:32:16 PM »

Hi, sorry for posting 2 times, I already wrote this in the German Sub-Forum, but I think this solution for a Navigation like mentioned in the title may be interesting for non-german-speakers too.
This solution uses the module show_menu2, therefore it should be installed:

Code:
<?php

ob_start
();
show_menu2(0SM2_CURRSM2_CURRfalse'[if(class=menu-current){[sib]}]''''''');
$current ob_get_contents();
ob_end_clean();

$previous $current 1;
$next $current 1;

ob_start();
show_menu2(0SM2_CURRSM2_CURRfalse'[if(class=menu-current){[level]}]''''''');
$child ob_get_contents();
ob_end_clean();

$parent $child 1;

show_menu2(0SM2_CURRSM2_CURRfalse'[if(sib='.$previous.'){<< previous [a][menu_title]</a>}]''''''');
echo(
' | ');
show_menu2(0SM2_ROOT+$parentSM2_CURRfalse'[if(class=menu-parent){[a][menu_title]</a>}]''''''');
echo(
' | ');
show_menu2(0SM2_CURRSM2_CURRfalse'[if(sib='.$next.'){[a][menu_title]</a> next >>}]''''''');

?>


Hope this code works on other projects, I'm not a specialist in PHP  grin
Logged

scott

Offline Offline

Posts: 2


« Reply #1 on: August 29, 2007, 10:47:37 AM »

Thanks Kralle,

Proof that if one searches enough, one usually doesn't have to do it himself. That's good because I am not a coder, so could never have figured this out.

Works for me.

To make it do what I wanted it to do, in case someone else wants to try it, is in my index.php I pasted the above code where I wanted it to show on the page (just experiment a bit--I'm on a testserver so mistakes are easy to tolerate).

Then I tried my hand for the first time at a little php editing.

Before the code from above, I put
Code:
<div id="prevnext">
and after it I put
Code:
</div>
. This way I could style it with CSS. The "prevnext" is just a word I chose, and it corresponds to the following text I put into my template's css document.

Code:
#prevnext{
color:#808080;
margin:60px 200px;
text-align:center;
}

I also didn't want the full page title to show, so from the code above I eliminated the
Code:
[menu_title]
calls.

Anyway, I probably used improper terminology in the above. I'm a total hack at all this, but I like explaining what I do manage to figure out.

So anyway, then I had the previous and next page on every page, so i wondered if there were a way to do it for just a page or a group of pages.



and if it works to do this is in a code section, probably i'll have to figure out how to style it. hmm...

well, if i figure it out, i'll post.

i just wanted to write this to lose my forum virginity and really, to thank Kralle. i'd be nowhere without this thread.

and of course, thanks to everybody involved with the project. so far i'm enjoying websitebaker.

.s
Logged
brofield

Offline Offline

Posts: 224


WWW
« Reply #2 on: August 29, 2007, 01:31:55 PM »

Great idea. Here is a bit of a cleanup that should work slightly faster. It requires the new version 4.3 to work correctly and replaces the php output buffering with the SM2 internal buffering.

<p class="navigation">
<?php
// get the required information
$info = show_menu2(0, SM2_CURR, SM2_START, SM2_ALL|SM2_BUFFER,
    '[if(class==menu-current){[level] [sib] [sibCount] [parent]}]', '', '', '');
list($nLevel, $nSib, $nSibCount, $nParent) = explode(' ', $info);

// show previous
$prv = $nSib > 1 ? $nSib - 1 : 0;
if ($prv > 0) {
    show_menu2(0, SM2_CURR, SM2_START, SM2_ALL,
        "[if(sib==$prv){[a][menu_title]</a> &lt;&lt;}]", '', '', '');
}
else echo '(no previous)';
echo ' | ';

// show up level
if ($nLevel > 0) {
    $lev = $nLevel - 1;
    show_menu2(0, SM2_ROOT, SM2_CURR, SM2_CRUMB,
        "[if(level==$lev){[a][menu_title]</a>}]", '', '', '');
}
else echo '(no parent)';
echo ' | ';

// show next
$nxt = $nSib < $nSibCount ? $nSib + 1 : 0;
if ($nxt > 0) {
    show_menu2(0, SM2_CURR, SM2_START, SM2_ALL,
        "[if(sib==$nxt){&gt;&gt; [a][menu_title]</a>}]", '', '', '');
}
else echo '(no next)';
?>
</p>


See the example at the top of the table at:
http://code.jellycan.com/sm2test/pages/enterprise.php

Regards,
B
« Last Edit: August 29, 2007, 01:44:16 PM by brofield » Logged
scott

Offline Offline

Posts: 2


« Reply #3 on: August 29, 2007, 08:49:52 PM »

great! thanks brofield!

  smiley
Logged
Mte90
Forum Team
*****
Offline Offline

Posts: 49


Italian Section Moderator and Translator


WWW
« Reply #4 on: July 14, 2009, 07:08:43 PM »

but a way to make this code for show the previous or next that are not on public exist?
Logged

www.mte90.net - Php , jQuery and other!
Pages: [1] Go Up Print 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!