How to get cparentID in page list's view
Permalink
Hello,
I have a page list with "beneath another page" selected. Let say the ID for the page is 10. In the page list controller, if I understand correctly, $cParentID is storing the page ID from the form. How can I send this variable to view. My intention is to get the URL of the page ID so I can assign it to the title of page list. Thanks
I have a page list with "beneath another page" selected. Let say the ID for the page is 10. In the page list controller, if I understand correctly, $cParentID is storing the page ID from the form. How can I send this variable to view. My intention is to get the URL of the page ID so I can assign it to the title of page list. Thanks
Blog
--- Category A
--- entry 1
--- entry 2
--- Category B
--- entry 1
--- entry 2
I have 2 page lists on Blog. I need each of them to have a link to Category A and Category B respectively. So in those page lists, I chose "another page" and pointed to corresponding category page. The category page ID seem to be stored as cParentID in controller and I need to retrieve it to form a link in view.
I got it working by assigning cParentID to an array and passed it through view function. However, glad to know we can access cParentID directly in view. Now, I got everything I need to make it works as intended. Thank you so much.
--- Category A
--- entry 1
--- entry 2
--- Category B
--- entry 1
--- entry 2
I have 2 page lists on Blog. I need each of them to have a link to Category A and Category B respectively. So in those page lists, I chose "another page" and pointed to corresponding category page. The category page ID seem to be stored as cParentID in controller and I need to retrieve it to form a link in view.
I got it working by assigning cParentID to an array and passed it through view function. However, glad to know we can access cParentID directly in view. Now, I got everything I need to make it works as intended. Thank you so much.
$parentPage = Page::getByID($cParentID); $parentName = $parentPage->getCollectionName(); <a href="<?php echo DIR_REL . "/index.php" . $parentPage->getCollectionPath(); ?>Link</a>
Nice.
Can you mark "best answer" to un-list this issue from "Unanswered Only" + For future google searches. Also in the future its better to add "tags" to your Q.
thanks :) )
Can you mark "best answer" to un-list this issue from "Unanswered Only" + For future google searches. Also in the future its better to add "tags" to your Q.
thanks :) )
** cParentID is from the DB table - so you dont need to set this variable to the view (C5 auto declare this var for you).
<?php echo $cParentID ?> //give the pageParent id
The cParentID is only integer you need to use getByID to get pageObject match to this ID.
Blog
--- post
--- post
--- post
----------------------------------------------------------
More methods for $parentPage. C5 docs: Getting Data about a Page:
http://documentation.concrete5.org/developers/working-with-pages/ge...
Start from Simple example ----------------------
See "hello-World" tutorial:
http://documentation.concrete5.org/developers/working-with-blocks/c...
Inside hello-World/view.php you will see:
So again you dont need to "Set" $field2 var only match the names you declare from your DB table columns
----------------------------------------------------------
In GENERAL - If you want to send data from the controller to the view read her:
http://documentation.concrete5.org/developers/working-with-pages/si...
Inside view.php