Home
Download
Add-ons
Help
Forum
Organisation
Project
Welcome,
Guest
. Please
login
or
register
.
March 18, 2010, 06:26:09 AM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
Interested in joining the WebsiteBaker team?
For more Information read
here
or on our
new website
.
110327
Posts in
15933
Topics by
9291
Members
Latest Member:
topwzp
WebsiteBaker Community Forum
English
Help & Support
(Moderators:
Argos
,
BerndJM
)
Navigation << previous | up | next >>
Pages:
[
1
]
Author
Topic: Navigation << previous | up | next >> (Read 3335 times)
Kralle
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
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
Offline
Posts: 224
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
Offline
Posts: 2
Re: Navigation << previous | up | next >>
«
Reply #3 on:
August 29, 2007, 08:49:52 PM »
great! thanks brofield!
Logged
Mte90
Forum Team
Offline
Posts: 48
Italian Section Moderator and Translator
Re: Navigation << previous | up | next >>
«
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
]
Jump to:
Please select a destination:
-----------------------------
General
-----------------------------
=> General Announcements
=> Security Announcements
=> Documentation
=> Guest Area & Off-Topic
-----------------------------
English
-----------------------------
=> Help & Support
=> Modules
=> Droplets (PHP code for use with Droplet module) & Snippets (raw PHP code)
=> jQuery
=> Templates, Menus & Design
=> WebsiteBaker Language Files
=> WebsiteBaker 2.x discussion
=> WebsiteBaker 3
=> Archive (posts up to 2007)
-----------------------------
Deutsch (German)
-----------------------------
=> Ankündigungen
=> Hilfe/Support
=> Module & Snippets
=> Templates & Design
=> Tutorials
=> jQuery
=> Diskussion über WB
=> Off-Topic
=> Archiv für Themen bis 2007
-----------------------------
Nederlands (Dutch)
-----------------------------
=> Aankondigingen
=> Hulp & Ondersteuning
=> Niet-Terzake (Off Topic)
-----------------------------
Francais (French)
-----------------------------
=> Help/Support
-----------------------------
Italiano (Italian)
-----------------------------
=> Help/Support
Loading...