Extras catalogue

firstPageLink

Latest release 11 years ago (January 19, 2015).

firstpagelink

  • By rainbowtiger

About

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 & usage

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.

At a glance

MODX 3 compatibility unknown. Based on our testing and community reports where available.

  • Developer rainbowtiger
  • Latest release January 19, 2015 (11 years ago)
  • First seen in SiteDash January 18, 2015 (11 years ago)
  • License GPLv2
  • MODX support 2+
  • Databases MySQL

Releases 1 indexed release

Changelog
MODX.com

1.0.4-pl

January 19, 2015

11 years ago

<p>Version 1.0.4</p><ul><li>make database query more universal (don't search for modResource class key only)</li><li>tested for compatibility with Revolution 2.3</li></ul><p>Version 1.0.3</p><ul><li>changed how weblinks are handled to allow for external link opening in new window</li><li>add check for deleted resource</li></ul><p>Version 1.0.2</p><ul><li>fixed home page reference for root-relative environments</li></ul><p>Version 1.0.1</p><ul><li>fixed instance where link to home page could look like this:  http:///</li></ul>

We've also seen 1 unverified version of firstPageLink in use, but don't list those as we've been unable of confirming they are official releases from an official source.