Jump to content


PageTrail


  • Please log in to reply
22 replies to this topic

#1 Guest_Alex_*

Guest_Alex_*
  • Guests

Posted 12 September 2004 - 12:36 PM

I have added a new snippet to the Snippet Library!

Snippet name: PageTrail
Author: Alex
Version: 1.0 (Final)
More info: View this snippet
Description:
This snippet generates a page trail to the current page.

Please feel free to comment on this snippet, suggest improvements, or simply praise my work! ;)

[This is an automatically created message]

#2 miels

miels

    Etomite Forum Newbie

  • Member
  • 39 posts

Posted 22 December 2004 - 11:45 AM

I'm quite new to all this, but I think something has been overlooked in this script.

The given code doesn't adapt to non-user-friendly URLs. The links are coded like this:
<a href='".$etomite->documentObject['id'].".html'>".$etomite->documentObject['pagetitle']."</a>
<a href='".$parent['id'].".html'>".$parent['pagetitle']."</a>

Here you see the .html extension has been used. But when you're not using userfriendly URL's those addresses don't exist. Instead the [~id~] link can be used. Here is my result:

$sep = " » ";

// end config
$ptarr = array();
$pid = $etomite->documentObject['parent'];
$ptarr[] = "<a href='[~".$etomite->documentObject['id']."~]'>".$etomite->documentObject['pagetitle']."</a>";

while ($parent=$etomite->getParent($pid)) {
    $ptarr[] = "<a href='[~".$etomite->documentObject['id']."~]'>".$parent['pagetitle']."</a>";
    $pid = $parent['parent'];
}

$ptarr = array_reverse($ptarr);
return join($ptarr, $sep);
But unfortunately there's something else. I believe something changed when I installd [Etomite Fork]1. When navigating to a document in a subfolder, the name of the subfolder is being omitted.

#3 vw53a

vw53a

    Likes Etomite Forums!

  • Member
  • PipPip
  • 393 posts

Posted 24 January 2006 - 12:16 PM

This script was working fine in 0.6.0, but now I've installed 0.6.1 RTM it has some strange behaviour.
I've made a new document in the root and call it 'folder' and set it as a folder. I create in this folder a new folder 'sub' and in that a new folder and call it 'subsub' and in that folder a document and call it ....ehm 'subsubsubdoc'. :)
Viewing folder, pagetrail shows: folder
Viewing sub, pagetrail shows: sub
Viewing subsub, pagetrail shows: folder >> subsub
Viewing subsubsubdoc, pagetrail shows: sub >> subsubsubdoc

In the last case one would expect: folder >> sub >> subsub >> subsubsubdoc

It seems to be skipping a level each time. How come? Whats wrong??
Its the default snippet from the Prelude-distro.

Edited by vw53a, 24 January 2006 - 12:18 PM.


#4 vw53a

vw53a

    Likes Etomite Forums!

  • Member
  • PipPip
  • 393 posts

Posted 25 January 2006 - 10:49 PM

Can someone confirm the above mentioned behaviour?
I've put PageTrail and Breadcrumbs both in the same template for testing and noticed that Breadcrumbs does do well, meaning it works as one would expect. This increases my feeling though that there's something wrong with this snippet.

#5 katherholt

katherholt

    Likes Etomite Forums!

  • Member
  • PipPip
  • 323 posts

Posted 25 January 2006 - 11:58 PM

Can someone confirm the above mentioned behaviour?
I've put PageTrail and Breadcrumbs both in the same template for testing and noticed that Breadcrumbs does do well, meaning it works as one would expect. This increases my feeling though that there's something wrong with this snippet.


I'm having the same issue here:
http://www.pawsouth.org/AdoptingOlderDogs.html
Have installed the latest RTM version.

It's also not working on this site: http://www.flowerybranchga.org/city_clerks_office.html - a new install.

#6 Ralph

Ralph

    Loves Etomite Forums!

  • Admin
  • 6,539 posts

Posted 26 January 2006 - 04:26 AM

IS this happening with the original PageTrail snippet or with the one in the RTM...??? Not that there should be a difference...

#7 vw53a

vw53a

    Likes Etomite Forums!

  • Member
  • PipPip
  • 393 posts

Posted 26 January 2006 - 09:05 AM

IS this happening with the original PageTrail snippet or with  the one in the RTM...??? Not that there should be a difference...

It's the one that came with the RTM-distro. And as said, Breadcrumbs which works essentially the same has not got this flaw. And Pagetrail that came as standard with the 0.6 distro (about 1.5 year ago) worked fine too.

:huh: :blink: :unsure:

#8 Ralph

Ralph

    Loves Etomite Forums!

  • Admin
  • 6,539 posts

Posted 26 January 2006 - 02:39 PM

It's the one that came with the RTM-distro. And as said, Breadcrumbs which works essentially the same has not got this flaw. And Pagetrail that came as standard with the 0.6 distro (about 1.5 year ago) worked fine too.

:huh:  :blink:  :unsure:

Interesting... Well, if anyone comes up with what makes the two different, and has a fix, feel free to post it here as a replacement for the existing RTM version...

#9 katherholt

katherholt

    Likes Etomite Forums!

  • Member
  • PipPip
  • 323 posts

Posted 26 January 2006 - 02:40 PM

IS this happening with the original PageTrail snippet or with  the one in the RTM...??? Not that there should be a difference...


I checked some older versions on my sites - the snippet is exactly the same. So that's not the problem. Here's the snippet:

================
PageTrail
Outputs the page trail, based on Bill Wilson's script
================

$sep = " &raquo; ";

// end config
$ptarr = array();
$pid = $etomite->documentObject['parent'];
$ptarr[] = "<a href='[~".$etomite->documentObject['id']."~]'>".$etomite->documentObject['pagetitle']."</a>";

while ($parent=$etomite->getParent($pid)) {
    $ptarr[] = "<a href='[~".$parent['id']."~]'>".$parent['pagetitle']."</a>";
    $pid = $parent['parent'];
}

$ptarr = array_reverse($ptarr);
return join($ptarr, $sep);

Karen

#10 katherholt

katherholt

    Likes Etomite Forums!

  • Member
  • PipPip
  • 323 posts

Posted 26 January 2006 - 04:33 PM

Another clue, Ralph:

http://www.flowerybranchga.org/muncipal_court.html

Shows 3rd level pagetrail - but not 2nd level.

#11 Ralph

Ralph

    Loves Etomite Forums!

  • Admin
  • 6,539 posts

Posted 26 January 2006 - 06:10 PM

Ok, call me a bonehead... I kept the wrong modified getParent() API function in the RTM... After looking at a backup development copy I realized that after testing alternative replacements that I selected the wrong version... I have posted the correct getParent() function below and it has been updated in the production code for inclusion in the next release... I never noticed until I checked my own site that there was definitely a problem... Color this one fixed...
 function getParent($id=-1, $active=1, $fields='id, pagetitle, description, alias, parent') {
  // returns document information for a given document identifier
  // $id is the identifier of the document whose parent is being requested
  // $active boolean (0=false|1=true) determines whether to return any or only an active parent
  // $fields is a comma delimited list of fields to be returned in a $key=>$value array
    if($id==-1 || $id=="") {
      $id = $this->documentObject['parent'];
    }
    if($id==0) {
      return false;
    } else {
      $tbl = $this->db."site_content";
      $activeSql = $active==1 ? "AND $tbl.published=1 AND $tbl.deleted=0" : "";
      $sql = "SELECT $fields FROM $tbl WHERE $tbl.id=$id $activeSql";
      $result = $this->dbQuery($sql);
      $parent = @$this->fetchRow($result);
      return $parent;
    }
  }


#12 mikef

mikef

    Loves Etomite Forums!

  • Member
  • PipPipPipPip
  • 1,551 posts

Posted 26 January 2006 - 06:14 PM

I think this version still won't work properly in an uncached snippet in a cached page, though?
(Probably not relevant here, but ...)

#13 katherholt

katherholt

    Likes Etomite Forums!

  • Member
  • PipPip
  • 323 posts

Posted 26 January 2006 - 06:30 PM

Ok, call me a bonehead... I kept the wrong modified getParent() API function in the RTM... After looking at a backup development copy I realized that after testing alternative replacements that I selected the wrong version... I have posted the correct getParent() function below and it has been updated in the production code for inclusion in the next release... I never noticed until I checked my own site that there was definitely a problem... Color this one fixed...

 function getParent($id=-1, $active=1, $fields='id, pagetitle, description, alias, parent') {
  // returns document information for a given document identifier
  // $id is the identifier of the document whose parent is being requested
  // $active boolean (0=false|1=true) determines whether to return any or only an active parent
  // $fields is a comma delimited list of fields to be returned in a $key=>$value array
    if($id==-1 || $id=="") {
      $id = $this->documentObject['parent'];
    }
    if($id==0) {
      return false;
    } else {
      $tbl = $this->db."site_content";
      $activeSql = $active==1 ? "AND $tbl.published=1 AND $tbl.deleted=0" : "";
      $sql = "SELECT $fields FROM $tbl WHERE $tbl.id=$id $activeSql";
      $result = $this->dbQuery($sql);
      $parent = @$this->fetchRow($result);
      return $parent;
    }
  }


Do I just add this code to be bottom of the "PageTrail" snippet? I updated my snippet and am still getting the same results as before. My snippet is called as [!PageTrail!].

#14 Ralph

Ralph

    Loves Etomite Forums!

  • Admin
  • 6,539 posts

Posted 26 January 2006 - 07:21 PM

Do I just add this code to be bottom of the "PageTrail" snippet? I updated my snippet and am still getting the same results as before. My snippet is called as [!PageTrail!].

No, I guess I forgot to mention that this function code replaces the getParent() API function in your index.php parser file...

#15 katherholt

katherholt

    Likes Etomite Forums!

  • Member
  • PipPip
  • 323 posts

Posted 26 January 2006 - 07:38 PM

No, I guess I forgot to mention that this function code replaces the getParent() API function in your index.php parser file...

Working perfectly now! Thank you.

#16 vw53a

vw53a

    Likes Etomite Forums!

  • Member
  • PipPip
  • 393 posts

Posted 27 January 2006 - 08:25 AM

Thanks, will try that later.

@Moderator: I guess most of this topic belongs to the 0.6.1 RTM bugs section and the solution should be in the rtm bug fixes then.

#17 katherholt

katherholt

    Likes Etomite Forums!

  • Member
  • PipPip
  • 323 posts

Posted 04 November 2006 - 02:42 AM

No, I guess I forgot to mention that this function code replaces the getParent() API function in your index.php parser file...


I guess this wasn't updated in the latest version of index.php (0.6.1.2 Final (PL:2)) - I had to update again to make the pagetrail function to work properly.

#18 katherholt

katherholt

    Likes Etomite Forums!

  • Member
  • PipPip
  • 323 posts

Posted 10 March 2007 - 10:49 PM

I'm having the same issue here:
http://www.pawsouth.org/AdoptingOlderDogs.html
Have installed the latest RTM version.

It's also not working on this site: http://www.flowerybranchga.org/city_clerks_office.html - a new install.


I'm having this problem again (not showing parent folders) in the "pagetrail" my latest web sites that use System 0.6.1 Final (PL:3) (Prelude) :

http://www.barry-etris.com/home.html
http://www.roswellmemorialday.com/index.html
http://www.bluebonnetdesigns.com/~whattodo/index.html

#19 katherholt

katherholt

    Likes Etomite Forums!

  • Member
  • PipPip
  • 323 posts

Posted 13 March 2007 - 03:20 PM

I'm having this problem again (not showing parent folders) in the "pagetrail" my latest web sites that use System 0.6.1 Final (PL:3) (Prelude) :

http://www.barry-etris.com/home.html
http://www.roswellmemorialday.com/index.html
http://www.bluebonnetdesigns.com/~whattodo/index.html

I replaced the code on /index.php with the code recommended by Ralph earlier in this forum and it's working again.
function getParent($id=-1, $active=1, $fields='id, pagetitle, description, alias, parent') { // returns document information for a given document identifier // $id is the identifier of the document whose parent is being requested // $active boolean (0=false|1=true) determines whether to return any or only an active parent // $fields is a comma delimited list of fields to be returned in a $key=>$value array   if($id==-1 || $id=="") {     $id = $this->documentObject['parent'];   }   if($id==0) {     return false;   } else {     $tbl = $this->db."site_content";     $activeSql = $active==1 ? "AND $tbl.published=1 AND $tbl.deleted=0" : "";     $sql = "SELECT $fields FROM $tbl WHERE $tbl.id=$id $activeSql";     $result = $this->dbQuery($sql);     $parent = @$this->fetchRow($result);     return $parent;   } }
You can see the pagetrail is working properly again here:
http://www.bluebonnetdesigns.com/~whattodo...acy-policy.html
http://www.barry-etris.com/song-reuben-james.html
http://www.roswellmemorialday.com/history-timeline.html

Thanks, Karen

#20 katherholt

katherholt

    Likes Etomite Forums!

  • Member
  • PipPip
  • 323 posts

Posted 08 October 2007 - 09:06 PM

I must be the only person using PageTrail, I had to make the same correction to index.php per Ralph's code above. Did it get missed in the System 0.6.1 Final (PL:4) (Prelude) version?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users