how to get $cobj from a php file inside the block's tools folder on page-list block
Permalink
Hi,
I have a page-list block on a page with a custom template. In the template, I changed the page links in order to open dialog and show the page attributes of that particular page.
So, I have listingdetails.php inside the block's tools folder. Now, I don't know how to get that one particular page object?
I knew that it was not going to work, however I tried this;
But it doesn't work. Should I need to include and helper or loader to that listingdetails.php file?
I think I need to send that information from the template to that php file inside the tools via ajax. But I need help for that. Can someone please help me out?
Thanks in advance.
I have a page-list block on a page with a custom template. In the template, I changed the page links in order to open dialog and show the page attributes of that particular page.
So, I have listingdetails.php inside the block's tools folder. Now, I don't know how to get that one particular page object?
I knew that it was not going to work, however I tried this;
echo $propertytype = $cobj->getAttribute('propertytype');
But it doesn't work. Should I need to include and helper or loader to that listingdetails.php file?
I think I need to send that information from the template to that php file inside the tools via ajax. But I need help for that. Can someone please help me out?
Thanks in advance.
You want to send the CollectionID (cID) of the page ($cobj) to the ajax tool, then have the tool code retrieve that page so it can get at it's attributes. If you can post the code from your page_list custom template and your tools code, I could show you how to do this.
Thank you so much Jordan.
Page-list custom template:
http://justpaste.it/bxb
If I am not wrong, we need to look at here;
Page-list custom template:
http://justpaste.it/bxb
If I am not wrong, we need to look at here;
<h3 class="ccm-page-list-title"> <?php $th = Loader::helper('concrete/urls'); $bt = $b->getBlockTypeObject(); ?> <a id="<?php echo $cobj->getCollectionID()?>" class="button eachlistinglink hastipsy" target="_blank" title="<?php echo t('All Details')?>" href="<?php echo $th->getBlockTypeToolsURL($bt)?>/listingdetails?cID=<?php echo $cobj->getCollectionID()?>"><?php echo $title;?></a> </h3>
Right now, there is nothing in the tools/listingdetails.php
but these are what I want to show in that dialog.
but these are what I want to show in that dialog.
I think the code you have in the page list template is correct. Now you just need to retrieve that cID in the tools file. This should work:
<?php defined('C5_EXECUTE') or die("Access Denied."); $cID = empty($_GET['cID']) ? 0 : $_GET['cID']; if (!empty($cID) && intval($cID) == $cID) { $cobj = Page::getByID($cID); echo $cobj->getAttribute('propertytype'); echo $cobj->getAttribute('pricerange'); echo $cobj->getAttribute('bedrooms'); echo $cobj->getAttribute('bathrooms'); } exit;
You are wonderful. Thank you thank you thank you so muchh.
By the way, while doing this I had an idea of creating a page attribute called "area" and giving it a name "main". Then on another page, creating a page-list and in the page-list template, can't we code something to show those areas for each page which differs from page to page? Anyways just an idea.
So, now I need to get the page which the link will go, to a variable with javascript. and use that variable in the php file inside the tools folder.
Please help.