Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Find out the navigation level?
#1
I'm writing my own breadcrumb-plugin right now. http://get-simple.info/forum/topic/610/s...n-setting/ is a bit too complicated to modify for a beginner like me.

Can somebody tell me if it's possible to find out the navigation level?
Some kind of counter maybe?

That counter should be on 3 when I'm on "Home" -> "Company" -> "About us".
And on 2 when I'm on "Home" -> "Company".

Possible?
Reply
#2
GetSimple never goes any deeper than 2 levels, and an expansion of this limit hasn't been planned (as of yet). So all you need to do is check whether $parent exists and is a valid non-empty string. If it doesn't exist or is empty you're at the top-level. If it exists and is a string, you're on a child page.
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#3
Zegnåt Wrote:GetSimple never goes any deeper than 2 levels, and an expansion of this limit hasn't been planned (as of yet). So all you need to do is check whether $parent exists and is a valid non-empty string. If it doesn't exist or is empty you're at the top-level. If it exists and is a string, you're on a child page.

Thanks for your fast answer.
The variable $parent does not seem to exist. How do you create it?
Furthermore I would need some kind of "get_parent_page_url()" and "get_parent_page_title()" to display the name and URL of the parent. I can't find anything about that in the GetSimple-Documentation.
My breadcrumb looks like this:
[Image: breadcrumb.png]
Reply
#4
If you want to access $parent from inside your function, you’re going to have to access the global:
Code:
function yourfunction() {
   global $parent;
   if (isset($parent)&&strlen(trim($parent))>0) {
      // When this page has a parent.
   } else {
      // When this page is on the top-level.
   }
}
To get the URL you can use the find_url function. This also takes care of the users settings like Fancy URLs.
Code:
$parentlink = find_url($parent);
I’m afraid there is no way at the moment to just get the title. You will have to open the XML data file and check the name inside your script.
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#5
Zegnåt Wrote:If you want to access $parent from inside your function, you’re going to have to access the global:
Code:
function yourfunction() {
   global $parent;
   if (isset($parent)&&strlen(trim($parent))>0) {
      // When this page has a parent.
   } else {
      // When this page is on the top-level.
   }
}
To get the URL you can use the find_url function. This also takes care of the users settings like Fancy URLs.
Code:
$parentlink = find_url($parent);
I’m afraid there is no way at the moment to just get the title. You will have to open the XML data file and check the name inside your script.

Thank you very much!
I've got one problem now though. "find_url($parent)" results in my root path, no matter where I am.
And how do I open the XML data file? Couldn't find anything in the documentation about it.

Thanks again.
Reply
#6
media-seven Wrote:"find_url($parent)" results in my root path, no matter where I am.

What do you mean? find_url() is also used by the script that generates your main menu and it should always output correct URLs. What does it do that you don’t want it to do?

media-seven Wrote:And how do I open the XML data file? Couldn't find anything in the documentation about it.

We haven’t documented every single internal function, but this would be getXML(). (As seen on line 42 of the current index.php.)

Something like this would probably handle it (untested):
Code:
function returnParentTitle($parent) {
   $parentdata = getXML(GSDATAPAGESPATH.$parent.'.xml');
   return $parentdata->title;
}
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#7
Zegnåt Wrote:
media-seven Wrote:"find_url($parent)" results in my root path, no matter where I am.

What do you mean? find_url() is also used by the script that generates your main menu and it should always output correct URLs. What does it do that you don’t want it to do?

media-seven Wrote:And how do I open the XML data file? Couldn't find anything in the documentation about it.

We haven’t documented every single internal function, but this would be getXML(). (As seen on line 42 of the current index.php.)

Something like this would probably handle it (untested):
Code:
function returnParentTitle($parent) {
   $parentdata = getXML(GSDATAPAGESPATH.$parent.'.xml');
   return $parentdata->title;
}


YEAH! Thank you sooo much!
I wish I could teleport myself to Sweden and give you a pie. Smile

I'm going to release my plugin soon, so everyone can enjoy it.
Reply
#8
media-seven Wrote:I wish I could teleport myself to Sweden and give you a pie. Smile
Well, I’m heading for Germany today … I’d take a Schwartzwalder please, those are pretty hard to get outside German speaking countries ;-)

I’m looking forward to see your plugin!
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply




Users browsing this thread: 1 Guest(s)