firstPageLink 1.0.4-pl

firstPageLink 1.0.4-pl

Released Jan 19, 2015 by rainbowtiger

Plugin to use with WayFinder, or you own custom coding, to link menu items with first page that has content, making all menus clickable, even if they are just containers. The script starts with the resource WayFinder would normally link to, and if it is a container only (no content) it will look down the page tree to find the first page with content and link to that page.

Download 5kb (985 downloads)
Downloads: 2,238
License: GPLv2
Requires Revolution 2.0.x or greater
Supports mysql

Plugin to use with WayFinder to link menu items with first page that has
content, making all menus clickable, even if they are just containers.
The script starts with the resource WayFinder would normally link to,
and if it is a container only (no content) it will look down the page
tree to find the first page with content and link to that page.

The property value "checkContainers" determines whether the script will require that a resource is set as a container, as well as having empty content, to skip over it in the page tree. Setting checkContainers to "yes" is useful if you want to leave some pages intentionally blank during development, knowing that you are going to fill them in later. The default is "no", meaning a resource only needs a blank content field to trigger the search down the page tree for a page with content.

The script returns the URL of the page.

This plugin was developed in Revolution 2.2.2, but should work well in older versions. Let me know if it is incompatible with the version you are using.

Installation Instructions

Install via package management. Then install WayFinder (if it isn't already), and create chunks to format the output. See MODx: The Official Guide by Bob Ray, pages 560-561, or visit this page:  http://codingpad.maryspad.com/2011/02/21/modx-revolution-for-complete-beginners-part-8-using-wayfinder-to-create-menus/for ideas about how to do this. Then change the WayFinder placeholder  [[+wf.link]]   to   [[!firstPageLink? &pid=`[[+wf.docid]]`]]    in your code.

For example, change this:

a href="[[+wf.link]]"

to this:

a href="[[!firstPageLink? &pid=`[[+wf.docid]]`]]"

The script takes a single variable, "pid", which should be the ID of the page in your menu for which you want the right link.

Version 1.0.4

  • make database query more universal (don't search for modResource class key only)
  • tested for compatibility with Revolution 2.3

Version 1.0.3

  • changed how weblinks are handled to allow for external link opening in new window
  • add check for deleted resource

Version 1.0.2

  • fixed home page reference for root-relative environments

Version 1.0.1

  • fixed instance where link to home page could look like this:  http:///
Version Released Author Downloads
2 Versions 1 Contributors 2,242 Downloads
1.0.1-pl May, 21 2012 rainbowtiger 1,256