Home
Download
Add-ons
Help
Forum
Organisation
Project
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
May 26, 2012, 01:43:16 AM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
Wollen Sie dem WebsiteBaker Team beitreten?
Nähere Informationen finden Sie unter
hier
und auf unserer
neuen Webseite
.
155533
Posts in
21713
Topics by
7738
Members
Latest Member:
Pattieardathfe
WebsiteBaker Community Forum
English
Droplets (PHP code for use with Droplet module) & Snippets (raw PHP code)
(Moderator:
Argos
)
ParentPage droplet modified to show top level if no parent
Pages: [
1
]
Go Down
Author
Topic: ParentPage droplet modified to show top level if no parent (Read 1197 times)
lausianne
WebsiteBaker Org e.V.
Offline
Posts: 155
ParentPage droplet modified to show top level if no parent
«
on:
October 27, 2009, 09:30:55 PM »
Hi,
I have grown really fond of droplets. A great advantage is that they can easily be modified without need to get into module programming.
I used the ParentPage droplet for a side menu. What was not nice in my case was that the droplet showed nothing (or "(no parent)") when on the top level. So I modified it slightly. What now works well for me is this:
Code:
$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 up level
if ($nLevel > 0) {
$lev = $nLevel - 1;
return show_menu2(0, SM2_ROOT, SM2_CURR, SM2_CRUMB|SM2_BUFFER, "[if(level==$lev){[ul][li][a][menu_title]</a></li></ul>}]", '', '', '');
}
else {
return show_menu2(0, SM2_ROOT, SM2_CURR, SM2_CRUMB|SM2_BUFFER);
}
The [ul/li] bit in the first return line was necessary to get the formatting right.
I wonder if such minor modifications are at all interesting to anyone, since it is kind of trivial for most people in this forum, I believe. Maybe someone can enlighten me what the level of sophistication is that a modification should meet to be worth posting.
Cheers,
Ralf.
Logged
Argos
Moderator
Offline
Posts: 2161
Re: ParentPage droplet modified to show top level if no parent
«
Reply #1 on:
November 09, 2009, 12:17:28 AM »
No need for this Ralf, the droplet maker (Ruud) has a tip on the bottom of the page
http://www.websitebakers.com/pages/droplets/official-library/navigation/parent-page.php
for this...
Logged
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
WB Showcase:
http://www.mywebsitebaker.com/pages/showcase.php?v&category_id=1242&count=30
----------------------------------------------------------------
Please don't request personal support, use the forums!
lausianne
WebsiteBaker Org e.V.
Offline
Posts: 155
Re: ParentPage droplet modified to show top level if no parent
«
Reply #2 on:
November 09, 2009, 08:21:07 AM »
Hi Argos,
in his tip he says this:
Quote
If you don't want to show anything if there is no parent page, replace the last line in return ' '; (Return a single whitespace)
I don't show "nothing", but always at least the top level. And I added [ul/li]-tags to get the formatting right.
Cheers, Ralf.
Logged
Argos
Moderator
Offline
Posts: 2161
Re: ParentPage droplet modified to show top level if no parent
«
Reply #3 on:
November 09, 2009, 12:22:18 PM »
Hi Ralf,
just curious: why would you want to show a link to the current page? Because that is what your code shows if there is no parent: a link to itself...
Logged
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
WB Showcase:
http://www.mywebsitebaker.com/pages/showcase.php?v&category_id=1242&count=30
----------------------------------------------------------------
Please don't request personal support, use the forums!
lausianne
WebsiteBaker Org e.V.
Offline
Posts: 155
Re: ParentPage droplet modified to show top level if no parent
«
Reply #4 on:
November 09, 2009, 03:19:24 PM »
Hi Argos,
right, a link to itself. The reason is simple: I use this for a side menu. The top level (e.g. "Home") is on the top of the menu. I want the menu to stay complete, whereever I am.
You don't remove items from any other menu, when you are on the page to which that item links, do you ...
The side menu disappears completely when there are no sub-pages. Somehow I found it simpler to use ParentPage than sm2 directly, don't remember exactly why.
Cheers, Ralf.
Logged
Argos
Moderator
Offline
Posts: 2161
Re: ParentPage droplet modified to show top level if no parent
«
Reply #5 on:
November 09, 2009, 04:09:01 PM »
Quote from: lausianne on November 09, 2009, 03:19:24 PM
Hi Argos,
right, a link to itself. The reason is simple: I use this for a side menu. The top level (e.g. "Home") is on the top of the menu. I want the menu to stay complete, whereever I am.
You don't remove items from any other menu, when you are on the page to which that item links, do you ...
The side menu disappears completely when there are no sub-pages. Somehow I found it simpler to use ParentPage than sm2 directly, don't remember exactly why.
Hi Ralf,
I understand what you want now. I was looking through the droplets, and I think
http://www.websitebakers.com/pages/droplets/official-library/navigation/sitemapchild.php
will do the same. Or is it still different? Well, if your solution works fine, than it's okay to use that of course.
Logged
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
WB Showcase:
http://www.mywebsitebaker.com/pages/showcase.php?v&category_id=1242&count=30
----------------------------------------------------------------
Please don't request personal support, use the forums!
ichmusshierweg
Offline
Posts: 23
Re: ParentPage droplet modified to show top level if no parent
«
Reply #6 on:
January 14, 2010, 02:48:17 AM »
Hi Ralf,
you are my hero of the day! That was exactly what I was looking for Thanks a lot.
I did some minor modifications to avoid theese formatting issues. May it is helpful for anybody.
Code:
$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 up level
if ($nLevel > 0) {
$lev = $nLevel - 1;
return show_menu2(0, SM2_ROOT, SM2_CURR, SM2_CRUMB|SM2_BUFFER, "[if(level==$lev){[a][menu_title]</a>}]", '', '', '');
}
else {
return show_menu2(0, SM2_ROOT, SM2_CURR, SM2_CRUMB|SM2_BUFFER, "[if(level==0){[a][menu_title]</a>}]", '', '', '');
}
That works fine but there is still one probleme left: Using the search-form.
If I to this, an error appiers: "Error in: ParentPage, no correct returnvalue." (Please take a look to the attached picture)
This mkes sense, because the search doesen't have no parent and the search is not part of show_menu2. Is there a way just to return a single word with som emodification in the "ParentPage-Code" above.
Thanks a lot guys, and regards from bavaria
Karsten
Logged
lausianne
WebsiteBaker Org e.V.
Offline
Posts: 155
Re: ParentPage droplet modified to show top level if no parent
«
Reply #7 on:
January 14, 2010, 08:17:13 AM »
Hi Karsten,
Thank you, I'm glad you find it useful.
Search: I have actually never used a Search field on a WB site ... so I wasn't aware of the problem.
But then, no top level page has a parent. I solved this in index.php, not ParentPage:
Code:
<div id="sidemenu">
<?php
$mb2
=
show_menu2
(
0
,
SM2_ROOT
+
1
,
SM2_ALL
,
SM2_TRIM
|
SM2_BUFFER
);
if (
$mb2
!=
''
) echo
'<div id="parent">[[ParentPage]]</div>'
.
$mb2
;
?>
</div>
This works where I applied it, because the side menu has a blank background and it does not disturb the design, when the side menu disappears completely. I don't know if that would work in your design.
You could still add other code to display the top level item in the side menu:
Code:
<?php
if (
$mb2
!=
''
) echo
'<div id="parent">[[ParentPage]]</div>'
.
$mb2
;
else echo
'<div id="parent">Search</div>'
; (or
some code to get the current top level item
)
?>
Just an idea.
Cheers,
Ralf.
Logged
Pages: [
1
]
Go Up
Jump to:
Please select a destination:
-----------------------------
General
-----------------------------
=> General Announcements
=> Security Announcements
=> Documentation
=> WebsiteBaker Website Showcase
=> Guest Area & Off-Topic
-----------------------------
English
-----------------------------
=> WebsiteBaker 2.9
===> Announcements
===> Help/Support
=====> Modules / Extensions
===> Suggestions
===> Software bugs
=> 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
=> WebsiteBaker 2.9
===> Ankündigungen
===> Hilfe/Support
=====> Module / Extensions
===> Vorschläge
===> Softwarefehler
===> Erfahrungs und Testberichte
=> 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
-----------------------------
Bakery (WB shop module)
-----------------------------
=> Bakery English
=> Bakery Deutsch
-----------------------------
KeepInTouch (Multi Contact Module)
-----------------------------
=> KeepInTouch English
=> KeepInTouch Deutsch
Loading...