Select data from another page
Permalink
Hi. I am trying to write custom block and need to link short version, few lines, of text from another existing page.
Any ideas?
Thanks.
Any ideas?
Thanks.
Here's a part of a template I wrote for use with the Page List (check thishttp://www.concrete5.org/community/forums/customizing_c5/modify_pag... to do something similar.
I will try it.
Tnx.
Tnx.
Could anyone provide any guidance on how to promote an image from a lower level page up.
My scenario is that I would like to promote the image on many event pages up to the parent events page as well as to the home page.
I've successfully used the tips here to pull the text based block content but need a prod in the right direction for an image.
In truth, I'm finding it hard to get info from the API docs and there is only so far that looking at existing examples can get you so any help would be appreciated.
Regards,
Dan.
My scenario is that I would like to promote the image on many event pages up to the parent events page as well as to the home page.
I've successfully used the tips here to pull the text based block content but need a prod in the right direction for an image.
In truth, I'm finding it hard to get info from the API docs and there is only so far that looking at existing examples can get you so any help would be appreciated.
Regards,
Dan.
look at the code above..
the block type isn't content but "image" in your case and anything else is pretty much the same..
add print_r($bi) to see what properties you get.
the block type isn't content but "image" in your case and anything else is pretty much the same..
add print_r($bi) to see what properties you get.
Thanks for your reply Remo.
However, I've set up my event pages so that content is constrained and controlled. Therefore, I have an 'Image' area that will only ever contain one image block (through defaults and advanced permissions).
Therefore, I make an assumption with my code in the page_list overridden template, meaning I just take the first element of the blocks array and have no need to iterate through filtering upon type - e.g.:
So I guess my follow up question is: are you referring to changing
to
in my example and if so where would I have found this information out myself?
That said, I've tried what you have suggested (or how I interpreted the suggestion) with no further joy.
I have to caveat this response in that I haven't really coded in PHP in earnest before so there could well be something I am not grasping so feel free to treat me like a blonde! ;)
Regards and thanks in advance,
Dan
However, I've set up my event pages so that content is constrained and controlled. Therefore, I have an 'Image' area that will only ever contain one image block (through defaults and advanced permissions).
Therefore, I make an assumption with my code in the page_list overridden template, meaning I just take the first element of the blocks array and have no need to iterate through filtering upon type - e.g.:
$imageBlocks = $cobj->getBlocks('Image'); if(sizeof($imageBlocks) > 0) { $imageURL = $imageBlocks[0]->getInstance()->content; }
So I guess my follow up question is: are you referring to changing
$imageURL = $imageBlocks[0]->getInstance()->content;
to
$imageURL = $imageBlocks[0]->getInstance()->image;
in my example and if so where would I have found this information out myself?
That said, I've tried what you have suggested (or how I interpreted the suggestion) with no further joy.
I have to caveat this response in that I haven't really coded in PHP in earnest before so there could well be something I am not grasping so feel free to treat me like a blonde! ;)
Regards and thanks in advance,
Dan
For the benefit of others like me...
As I only wanted the URL to be passed, I've now used:
and then echo'd out the $imageURL in the right location. I found the above code in the controller.php for the image block.
Regards,
Dan.
As I only wanted the URL to be passed, I've now used:
$imageURL = $imageBlocks[0]->getController()->getFileObject()->getRelativePath();
and then echo'd out the $imageURL in the right location. I found the above code in the controller.php for the image block.
Regards,
Dan.
yes, this is better!
I don't like getContentAndGenerate a lot. This shouldn't be part of the controller.
Using getFileObject is much better and should work fine as long as the image block itself doesn't change. Very unlikely to happen I think, but calling a blockcontroller is probably not part of "the official API"..
But I'd use it as well..
I don't like getContentAndGenerate a lot. This shouldn't be part of the controller.
Using getFileObject is much better and should work fine as long as the image block itself doesn't change. Very unlikely to happen I think, but calling a blockcontroller is probably not part of "the official API"..
But I'd use it as well..
Thanks for your feedback.