Does anyone know an easy way to get a content item’s navon, and a navon’s landing page content item in a JEXL expression. I’m needing to do something like this in a location scheme expression.
In the PSO Toolkit, there is are a series of “isLandingPage” Jexl functions which return booleans if the current item is a landing page or one for it’s own Navon. We’ve used this in the past (for example) to name all Landing Pages “index.html”. Is this the type of functionality you’re looking for?
M.
$user.psoRelationships.isLandingPageInFolderInt(contentid, folderid) [boolean] is this page referenced in the landing page slot
$user.psoRelationships.isLandingPageGuid(guid) [boolean] is this page referenced in the landing page slot
$user.psoRelationships.isLandingPageInFolder(contentid, folderid) [boolean] is this page referenced in the landing page slot in the current folder
$user.psoRelationships.isLandingPage(contentid) [boolean] is this page referenced in the landing page slot
$user.psoRelationships.isLandingPageInFolderGuid(contentGuid, folderGuid) [boolean] is this page referenced in the landing page slot
Not quite what I’m looking for… Perhaps I just don’t know what I should be asking… so let me describe my situation and see what you recommend doing:
[ol]
[li]Each Navon in the CX folder hierarchy has a boolean field called “ispubroot”.[/li][li]I want to build a location scheme that will output an SEO-Friendly version of display titles of the attached Landing Pages up to the nearest Navon with ispubroot == true.[/li][li]If the content item is not a landing page, its own display title should be made SEO-friendly and be postfixed with .html (landing pages get index.html).[/li][/ol]
Example:
NavTree {//Sites/MySite/Nav - Home} has landing page of {//Sites/MySite/Home}
Item {//Sites/MySite/Home} has display title of “Home”
Navon {//Sites/MySite/Aplha/Nav - Alpha} has landing page of {//Sites/MySite/Alpha/Landing - Alpha} and ispubroot = false.
Item {//Sites/MySite/Alpha/Landing - Alpha} has display title of “Alpha Category”
Navon {//Sites/MySite/Alpha/Foo/Nav - Foo} has landing page of {//Sites/MySite/Alpha/Foo/Landing - Foo} and ispubroot = true.
Item {//Sites/MySite/Alpha/Foo/Landing - Foo} has display title of “Enterprise Foo Products”
Navon {//Sites/MySite/Alpha/Foo/Bar/Nav - Bar} has landing page of {//Sites/MySite/Alpha/Foo/Bar/Landing - Bar} and ispubroot = false.
Item {//Sites/MySite/Alpha/Foo/Bar/Landing - Bar} has display title of “Foo Bar Family”
Item {//Sites/MySite/Alpha/Foo/Bar/Product - Baz} has display title of “Foo Bar Baz”
So, the published files would have the respective paths:
$siteroot/index.html
$siteroot/alpha-category/index.html
$siteroot/enterprise-foo-products/index.html
$siteroot/enterprise-foo-products/foo-bar-family/index.html
$siteroot/enterprise-foo-products/foo-bar-family/foo-bar-baz.html
The idea is to allow a folder from deep in the CX hierarchy to publish to the top of the output file system hierarchy.
Is this possible with the built in JEXL extensions? with PSOToolkit Extensions? Or, do I need to write my own extension?
Alternately, I could use a custom property on a folder instead of a Navon.
Curious to see what your solution was I am interested in doing the same thing.
We have done this very thing, using the functions that Mr. Matonis mentions. One of our location schemes is as follows:
$isLanding=$user.psoRelationships.isLandingPage($sys.item.getProperty(‘rx:sys_contentid’).String);
if ($isLanding == ‘false’) {$prefix = $rx.location.getFirstDefined($sys.item,‘rx:displaytitle,rx:filename,rx:sys_title’,‘item’).replaceAll(‘+’,‘-’).replaceAll(‘[^A-Za-z0-9_-]’,‘’).replaceAll(‘[-]+’,‘-’).toLowerCase().replaceAll(‘.list.$’,‘’)+$rx.location.getFirstDefined($sys.item,‘rx:activeimg_ext,rx:sys_suffix,rx:img1_ext’, ‘/index.html’).toLowerCase();} else {$prefix=‘index.html’;}
$URL = $sys.pub_path.toLowerCase().replaceAll(‘/currentdirector/’,‘/’).replaceAll(‘.’,‘-’)+$sys.template.prefix.replaceAll(‘.’,‘-’) +$prefix;
There’s a lot of stuff in here to “sanitize” our URLs, but the key bit for your question is:
$isLanding=$user.psoRelationships.isLandingPage($sys.item.getProperty(‘rx:sys_contentid’).String);
if ($isLanding == ‘false’) {$prefix = …
Basically, we check this and based on if it’s a landing page or not, we do different things to construct the URL.
Another tech finished up the publishing scheme for this project and they elected to do it differently. However, from reading the docs a little more and some more exposure to location scheme bindings and folder settings…
It follows, then, that something like the following should work:
Location Scheme Expression:
$isLanding=$user.psoRelationships.isLandingPage($sys.item.getProperty('rx:sys_contentid').String);
$t = $sys.pub_path.substring($sys.pub_path.lastIndexOf('//') + 1);
while(!empty($t) && $t.startsWith('/')) { $t = $t.substring(1); }
$filename = $rx.cond.choose($isLanding == 'false', $sys.template.prefix + $sys.item.getProperty('rx:filename').String, 'index');
$t + $filename + $rx.location.getFirstDefined($sys.item,'rx:sys_suffix', '.html')
I’m assuming, here, that a shared field called “filename” is available and used for all content items that use this location scheme. If I were to SEO-ize a different field, I’d probably want to write a JEXL extension to do so to make the expression easier to read, but it’s not as important for this discussion… the logic in Duane’s implementation should do the job if you want to do everything directly in the expression.
So, each folder can have its path manually set in the folder properties in the Content Explorer. The $sys.pub_path starts with this value from the nearest ancestor CX folder with a sys_pubFilename value that starts with ‘/’ and also contains the relative CX path from that point to the current CX directory.
(explaining the $t bit: this should allow you to start a folder’s sys_pubFilename property with a ‘/’ character to indicate that it should be a root. The while loop then strips out any excess / characters at the beginning of the path.)
So, in my example from earlier,
Folder //Sites/MySite/Alpha has property
sys_pubFilename = /alpha-category
Folder //Sites/MySite/Alpha/Foo has property
sys_pubFilename = /enterprise-foo-products
Folder //Sites/MySite/Alpha/Foo/Bar has property
sys_pubFilename = /foo-bar-family
Can anyone verify that this will work as intended?
Gah! typo.
Folder //Sites/MySite/Alpha/Foo/Bar has property
sys_pubFilename = foo-bar-family
no ‘/’ is supposed to be in the last one there.