Start
Help
Forum
Addons
Project
Welcome,
Guest
. Please
login
or
register
.
July 05, 2009, 05:02:24 AM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
Hier findest du alle Infos zur
Website Baker - Version 2.8.
85293
Posts in
13125
Topics by
8214
Members
Latest Member:
Nebz
Website Baker Community Forum
English
Help/Support
(Moderators:
Argos
,
BerndJM
)
Navigation << previous | up | next >>
Pages:
[
1
]
Author
Topic: Navigation << previous | up | next >> (Read 2627 times)
Kralle
Pending Apprentice Baker
Offline
Posts: 14
Navigation << previous | up | next >>
«
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
(
0
,
SM2_CURR
,
SM2_CURR
,
false
,
'[if(class=menu-current){[sib]}]'
,
''
,
''
,
''
);
$current
=
ob_get_contents
();
ob_end_clean
();
$previous
=
$current
-
1
;
$next
=
$current
+
1
;
ob_start
();
show_menu2
(
0
,
SM2_CURR
,
SM2_CURR
,
false
,
'[if(class=menu-current){[level]}]'
,
''
,
''
,
''
);
$child
=
ob_get_contents
();
ob_end_clean
();
$parent
=
$child
-
1
;
show_menu2
(
0
,
SM2_CURR
,
SM2_CURR
,
false
,
'[if(sib='
.
$previous
.
'){<< previous [a][menu_title]</a>}]'
,
''
,
''
,
''
);
echo(
' | '
);
show_menu2
(
0
,
SM2_ROOT
+
$parent
,
SM2_CURR
,
false
,
'[if(class=menu-parent){[a][menu_title]</a>}]'
,
''
,
''
,
''
);
echo(
' | '
);
show_menu2
(
0
,
SM2_CURR
,
SM2_CURR
,
false
,
'[if(sib='
.
$next
.
'){[a][menu_title]</a> next >>}]'
,
''
,
''
,
''
);
?>
Hope this code works on other projects, I'm not a specialist in PHP
Logged
Kostenlose Links / Free Links
scott
Pending Apprentice Baker
Offline
Posts: 2
Re: Navigation << previous | up | next >>
«
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
Semi-Master Baker
Offline
Posts: 218
Re: Navigation << previous | up | next >>
«
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> <<}]", '', '', '');
}
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){>> [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
Posts: 2
Re: Navigation << previous | up | next >>
«
Reply #3 on:
August 29, 2007, 08:49:52 PM »
great! thanks brofield!
Logged
Pages:
[
1
]
Jump to:
Please select a destination:
-----------------------------
General
-----------------------------
=> Announcements
===> Security Announcements
=> Guest Area and Off-Topic
=> Website Showcase
-----------------------------
English
-----------------------------
=> Help/Support
===> Help/Support of WB2.7.x core
=> Website Baker Development
===> Website Baker 3
=> Documentation
=> Templates
=> Modules
===> Code Snippets
=> Languages
=> Archive
-----------------------------
Deutsch (German)
-----------------------------
=> Ankündigungen
=> Hilfe/Support
===> Templates, Module & Co.
===> Hilfe/Support von WB2.7.x core
=> Diskussion über WB
===> jQuery
=> Off-Topic
=> Archiv
-----------------------------
Nederlands (Dutch)
-----------------------------
=> Aankondigingen
=> Help / Support
===> WB Core
===> Templates, Modules & Languages
=> WB Discussie
=> Niet-Terzake (Off Topic)
-----------------------------
French
-----------------------------
=> Help/Support
-----------------------------
Italian
-----------------------------
=> Help/Support
Loading...