Display block posting dates

Permalink
Hello
i have recently buid a website using C5,http://www.dietdelightscenter.com
one of my client demand is to display the posting date under each testimonial in the testimonials page, knowing that each testimonials section is added using block
the link for this page is
http://www.dietdelightscenter.com/index.php?cID=125...
can you please help me how can i dispay the posted date of each block?
Thankyou in advanced

moussamhanna
 
TMDesigns replied on at Permalink Reply
TMDesigns
Hi,

you can use

$block->getBlockDateAdded()
to get the date. you just then need to format the date using php.

For more details you can get for blocks check out this post
http://www.concrete5.org/documentation/developers/blocks/working-wi...

or if this is a little too much maybe look to use one of these addons.
http://www.concrete5.org/marketplace/addons/-/view/?submit_search=1...
moussamhanna replied on at Permalink Reply
moussamhanna
Hi @tmdesigns
i have used the above code,
but its not seems to work!
the page is giving me this error "Fatal error: Call to a member function getBlockDateAdded() on a non-object in /home2/developa/public_html/dietdelightscenter.com/concrete/single_pages/dietdelights-testimonials1.php on line 44"
i am using the below code
<?php
$a = new Area('text in testimonials here');
$a->display($c);
$block->getBlockDateAdded()
?>
im a doing it the wrong way :(
moussamhanna replied on at Permalink Reply
moussamhanna
@TMDesigns
any assistance on the above?
WebcentricLtd replied on at Permalink Best Answer Reply
hi,
I'll see if I can give you a pointer. You've added your code to the wrong place.
It actually needs to go inside the block's view itself.

The general way of doing something like this is to create a custom template from the block's view and then add your custom code so you don't change the base block.

If you grab a copy of the view from your block and just look through it it might give you some clues.

Take a look at the following links:

http://www.concrete5.org/documentation/general-topics/custom-templa...

http://www.concrete5.org/documentation/how-tos/designers/change-how...

Remember though - you want to create a custom template - not actually change any of the block's code directly.
moussamhanna replied on at Permalink Reply
moussamhanna
thankyou so much @AndyJ
this was soo helpful

Regards
moussamhanna replied on at Permalink Reply
moussamhanna
@AndyJ
hello sorry for bringing this issue back,
but i have created the template perfectly fine, still something wrong with the code
i always get the message "Fatal error: Call to a member function getBlockDateAdded() on a non-object in ...."
my code is
<?php
$block->getBlockDateAdded()
?>

can anybody provide me with the full php code?
or tell me whats wrong with mine?
Thanks
WebcentricLtd replied on at Permalink Reply
hi,
where did you put this code?
It's basically saying $block is not an object.
moussamhanna replied on at Permalink Reply
moussamhanna
Hi @AndyJ
i have created a php file inside /blocks/content/templates/postdate.php
blocks folder was originaly empty
i was able to select "post date" from custom template in block editing,
but the problem is from the code itself, i am writing this code wrong!
can you provide me with the complete code?
kindly find below the view.php code inside concrete/blocks/content
<?php
    defined('C5_EXECUTE') or die("Access Denied.");
    $content = $controller->getContent();
    print $content;
?>


kindly find below the postdate.php code inside /blocks/content/templates
<?php
$block->getBlockDateAdded()
?>


Thanks
WebcentricLtd replied on at Permalink Reply
Hi,
I think things are a little confused.
Which version of Concrete5 are you using?
moussamhanna replied on at Permalink Reply
moussamhanna
i am Currently Running 5.6.3.1
the latest version