Welcome, Guest. Please login or register.
August 29, 2008, 10:45:34 AM

Login with username, password and session length
Search:     Advanced search
Please check out the Documentation available and use the advanced forum search, before posting in the forum - thanks.
Bitte lies zuerst die Dokumentation und benutze die Advanced Forensuche, bevor Du einen neuen Beitrag erstellst - danke.
Bekijk alstublieft eerst de Documentatie en gebruik de Advanced Forum Zoekfunctie, voor dat u een post maakt in het forum - Hartelijk dank.
61304 Posts in 9886 Topics by 5887 Members
Latest Member: vunh
* Home Help Search Login Register
+  Website Baker Community Forum
|-+  English
| |-+  Help/Support
| | |-+  Navigation << previous | up | next >>
Pages: [1] Go Down Print
Author Topic: Navigation << previous | up | next >>  (Read 1480 times)
Kralle
Pending Apprentice Baker
**
Offline Offline

Posts: 14

336913830
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
Pending Apprentice Baker
**
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
Senior Baker
*****
Offline Offline

Posts: 199


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
Pending Apprentice Baker
**
Offline Offline

Posts: 2


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

great! thanks brofield!

  smiley
Logged
Pages: [1] Go Up Print 
Jump to:  

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