Displaying link to site page
Permalink 1 user found helpful
In my controller.php I have
$page = Page::getByID($pageref);
I need to retrieve the page name and full URL to the page on my site
Ie
Name Page to display
URL local host/cc5/index.php/team/about
Appreciate for any help on what code to place in controller.php and/or view.php for my block.
$page = Page::getByID($pageref);
I need to retrieve the page name and full URL to the page on my site
Ie
Name Page to display
URL local host/cc5/index.php/team/about
Appreciate for any help on what code to place in controller.php and/or view.php for my block.
Many thank for the reply but I am still not getting what I need.
In my block I have the following
form.php
<div class="form-group">
<label class="control-label" for="pagecatalog1"><?=t('Catalog 1')?></label>
<?php
$pageSelector = Loader::helper('form/page_selector');
echo $pageSelector->selectPage('pagecatalog1', $pagecatalog1, 'ccm_selectSitemapNode');
?>
</div>
controller.php
public function view()
{
$nh = Loader::helper('navigation');
$page = Page::getByID($pagecatalog1);
$url = $nh->getLinkToCollection($page);
$this->set('pagecatalog1', LinkAbstractor::translateFrom($url));
}
view.php
<div>
<div><?php echo $pagecatalog1 ?></div>
</div>
result is
http://localhost/cc5_dev/index.php?cID=...
Note I have check the database and I have a value in the table for pagecatalog1 which is 213 and this corresponds to the page I need to be displayed if I enterhttp://localhost/cc5_dev/index.php?cID=213... displays pagehttp://localhost/cc5_dev/index.php/team/about...
I need to get this result
http://localhost/cc5_dev/index.php/team/about...
Any help to point out my error would be appreciated.
In my block I have the following
form.php
<div class="form-group">
<label class="control-label" for="pagecatalog1"><?=t('Catalog 1')?></label>
<?php
$pageSelector = Loader::helper('form/page_selector');
echo $pageSelector->selectPage('pagecatalog1', $pagecatalog1, 'ccm_selectSitemapNode');
?>
</div>
controller.php
public function view()
{
$nh = Loader::helper('navigation');
$page = Page::getByID($pagecatalog1);
$url = $nh->getLinkToCollection($page);
$this->set('pagecatalog1', LinkAbstractor::translateFrom($url));
}
view.php
<div>
<div><?php echo $pagecatalog1 ?></div>
</div>
result is
http://localhost/cc5_dev/index.php?cID=...
Note I have check the database and I have a value in the table for pagecatalog1 which is 213 and this corresponds to the page I need to be displayed if I enterhttp://localhost/cc5_dev/index.php?cID=213... displays pagehttp://localhost/cc5_dev/index.php/team/about...
I need to get this result
http://localhost/cc5_dev/index.php/team/about...
Any help to point out my error would be appreciated.
$page->getCollectionName() & $page->getCollectionLink() should do the trick. Both are listed at the link @linuxoid shared!!
Edit: Quick glance at your code looks like second line of controller view may need to be:
$page = Page::getByID($this->pagecatalog1);
Edit: Quick glance at your code looks like second line of controller view may need to be:
$page = Page::getByID($this->pagecatalog1);
Thanks for your support in this issue I was having.
As a reference for others
As a reference for others
controller.php $nh = Loader::helper('navigation'); $page = Page::getByID($this->pagecatalog1); if ( $this->pagecatalog1 == '0') { $this->set('pagecatalog1', ''); } else { // Output:http://localhost/cc5_dev/index.php/team/about... $this->set('pagecatalog1', $page->getCollectionLink()); // Output: About // $this->set('pagecatalog1', $page->getCollectionName()); } view.php <?php if ( $pagecatalog1 != "" ) {
Viewing 15 lines of 22 lines. View entire code block.
https://github.com/shahroq/whale_c5_cheat_sheet#pages-collections...