Page Block for Concrete5

Page Block for Concrete5

Use this block to easily display any page properties and custom fields in a block inside another page!
An example of usage is to feature some article from a page burried deep down in the site map, in the home page, or a more visible page.

The default view will print all page properties and custom fields, but of course you can easily override it.

The $page variable contains the selected page collection object.
Advanced users can use this varible to do anything they want using the standard collection, and collection helpers functions.

Otherwise, you can use the following functions to get the properties you want for the selected page:

$controller->getName();
$controller->getLink();
$controller->getDescription();
$controller->getCustomFields();
$controller->getValue('the_handle');
(where the_handle is the Page Attribute handle as defined in the dashboard under "Pages and Themes / Page Types")

Some page attributes can accept extra parameters:

If the attribute is of type DATE, then you can pass a date formating string as the first parameter, as defined here: http://nz.php.net/manual/en/function.date.php
E.g: $controller->getValue('my_date_handle',"d m Y @ h:iA");

If the attribute is of type IMAGE, then you can pass the maxWidth and maxHeight as parameters.
Default maxWidth and maxHeight are 200.
E.g: $controller->getValue('my_image_handle',120,80);

Also included is a sample template for the Page List block which will use the Page Block to display the pages.

As an example, this page contains a Page Block referring to the Area Splitter page in the sidebar.

Download the block here:

For Concrete 5.3.3 or later: page_block.zip

Enjoy!

Comments:

Posted by James on
Wont allow me to select a page. and can it be tweeked to show a page content
Posted by admin on
mmm... which version of c5 are you running ?
I've only tested it on 5.3.1.1
Regarding the content, it can be done but it requires some more advanced c5 knowledge. You would need to put a code similar to this (untested) in a custom template:

$blocks = $page->getBlocks('Main');
foreach($blocks as $block){
$bv = new BlockView();
$bv->render($block);
}
Posted by mike on
Very useful block - thanks!

Could you add an another example of how to add a custom template? I tried what you posted above, but it doesn't seem to work.

I just need to wrap the output in various SPANs with classes...
Posted by Matt on
Ok, first things first. Do you know how to apply custom templates in general to a block? If not, there's a great tutorial here: http://www.codeblog.ch/2009/03/concrete5-templates/ , but basically, you create a folder called "templates" inside the block folder, make a copy of the file view.php and put it inside there with a different name, and then when you're editing the page you can select "custom template" from the menu that appears when you click on the block (after you'e added it to the page).
Ok, if you got this far, you can now modify your new template file. If you're more specific about what you need there I'll be able to help.
Cheers,

Matt
Posted by rn on
Thx matt!
Regards :)
Posted by Pritam on
Hi Matias,

Thank you for posting this block works great, however i am still unable to remove the unwanted fields from showing up, I tried following the instructions mentioned in the posts above but no luck !!
Posted by Pritam on
Hey Mathias,

Thanks once again, I got it working .

Cheers !!
Posted by Brian on
Hey Matias - love this block, comes in very handy. It seems like there's an issue with added the block to the page defaults when using a custom template - throws a php error "Call to a member function getAttributeType() on a non-object...". It doesn't happen with the default view.php template, only when I start specifying specific attributes to use - for example - any ideas? Thanks alot mnan!
Posted by Stik on
Hey Matias,
I am relative new to C5, and i would like to create block with slider. If I am honest I am trying to create it a few days now and now I find out your site on the Internet. I would like to put this one to my site http://sixrevisions.com/tutorials/javascript_tutorial/create-a-slick-and-accessible-slideshow-using-jquery/
and made it look similar to this site: http://www.promark.com. Can you please help me?

Thanks a lot!
Posted by Dan on
Matias,

I recently installed C5 (and updated to v. 5.4.1.1), for the first time...I'm a bit of a n00b with blocks in general. I've installed the block successfully, but whenever I try to add the Page Block to any editable area, I get the following error:

http://dl.dropbox.com/u/778166/Concrete5/Page-Block-Error.png

Any ideas on how I can fix it and get this Block working?

Thanks in advance...
Posted by admin on
Ok, fixed
Posted by Pritam on
Hi Mathias,

I upgraded one of my sites where page block is being used to 5.4.1.1, and found that when I attempt to add this block, the Select Page link appears disabled and no other options appear, I just saw your comment "Ok, fixed" and I re-downloaded the package from this page and tried to compare the controller.php file and found to some code changes in the two, so i tried replacing the controller.php from the existing page block used by me with the new controller.php but still it stays disabled.

Hope you can help.

Thank you