Forgot your password?
Getting & Giving Support
Wolf CMS books section
This function1) makes it possible always to produce a correct and current url to the page despite it possibly having moved from its original position in the page hierarchy. It does this by using the page's id.2)
See also: findById(), linkById()
<?php echo Page::urlById(3); ?>
where “3” in the example above is the “id” of the targetted page. It will produce the corresponding URL, e.g. http://www.example.com/about_us
To find out what the ID of a given page is, either look on the “metadata” tab, or hover above the page's title or icon in the main admin page listing, where the ID will appear as a tooltip.
Using a simple variable for the ID will not pass the filter test set by the urlById() function. In other words, something like this:
<?php echo Page::urlById($article->id()); ?>
will throw an error. It is possible to set the ID number dynamically, but it requires an extra step, wrapping the variable for the ID in with the PHP intval() function, like this:
$articleId = intval($article->id());
With this in place, the urlById() function will work as expected.