use in combination with designer content
Permalink Browser Info Environment
Hi there,
I've made a custom block with designer content. Containing 1: thumbnail, 2: big image, 3: some text.
Now i want to use the pagelist teaser to show just the thumbnail (first in row in the block). But i get the whole content of the block in the teaser list.
Can i change it, so it just shows the thumbnail from the block content?
I've made a custom block with designer content. Containing 1: thumbnail, 2: big image, 3: some text.
Now i want to use the pagelist teaser to show just the thumbnail (first in row in the block). But i get the whole content of the block in the teaser list.
Can i change it, so it just shows the thumbnail from the block content?
Type: | Discussion |
---|---|
Status: | New |
Hi Jordan, thanks for your quick reply! But it's not working completely yet...
I've changed all the code like your examples, but then both the teaser-list plus the actual page were getting errors.
Now i have this in my custom block controller:
Note that i changed the inserted code like it looks in public function view() {
This took away the error in the actual page.
The teaser helper looks like this now:
But it's giving me this error:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /var/www/g45287/fotokunstkado.nl/subdomains/concrete/packages/page_list_teasers/helpers/page_list_teasers.php on line 35
Line 35 is this line:
Do you know where i go wrong?
I've changed all the code like your examples, but then both the teaser-list plus the actual page were getting errors.
Now i have this in my custom block controller:
public function getSearchableContent() { return $this->field_2_wysiwyg_content; } //Added for teasers public function teaserThumbnail() { return $this->set('field_1_image', $this->get_image_object($this->field_1_image_fID, 201, 140, true)); } //End added for teasers public function view() { $this->set('field_1_image', $this->get_image_object($this->field_1_image_fID, 201, 140, true)); $this->set('field_3_image', $this->get_image_object($this->field_1_image_fID, 0, 0, false)); $this->set('field_2_wysiwyg_content', $this->translateFrom($this->field_2_wysiwyg_content)); }
Note that i changed the inserted code like it looks in public function view() {
This took away the error in the actual page.
The teaser helper looks like this now:
//Added for designercontent block } else if ($blockType == 'testblok') { //<--change this to the block type handle you entered in the Designer Content dashboard when creating the custom block $thumb = $blockForContent->teaserThumbnail(); echo "<img src=\"{$thumb->src}\" width=\"{$thumb->width}\" height=\"{$thumb->height}\" alt="" />"; //End added for designercontent block } else { $blockForDisplay->display(); } echo $blockWrapperEnd;
But it's giving me this error:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /var/www/g45287/fotokunstkado.nl/subdomains/concrete/packages/page_list_teasers/helpers/page_list_teasers.php on line 35
Line 35 is this line:
echo "<img src=\"{$thumb->src}\" width=\"{$thumb->width}\" height=\"{$thumb->height}\" alt="" />";
Do you know where i go wrong?
Yay! I figured it out and even added the alt tag from the custom block!
In controller.php for custom block i added:
In page_list_teasers.php i added:
Note that there were missing some escapes in your original code for the alt:
Thank you SO MUCH for handing me the right direction Jordan!!
In controller.php for custom block i added:
//Added for teasers public function teaserAlt() { return $this->field_1_image_altText; } public function teaserThumbnail() { return $this->get_image_object($this->field_1_image_fID, 201, 140, true); } //End added for teasers
In page_list_teasers.php i added:
//Added for designercontent block } else if ($blockType == 'testblok') { //<--change this to the block type handle you entered in the Designer Content dashboard when creating the custom block $thumb = $blockForContent->teaserThumbnail(); $thumbAlt = $blockForContent->teaserAlt(); echo "<img src=\"{$thumb->src}\" width=\"{$thumb->width}\" height=\"{$thumb->height}\" alt=\"{$thumbAlt}\" />"; //End added for designercontent block
Note that there were missing some escapes in your original code for the alt:
alt=""
Thank you SO MUCH for handing me the right direction Jordan!!
You're welcome! Sorry about the alt tag error there! Glad you got it figured out, and this will be a great resource for other people in the future who want to do similar things.
Hi Jordan, I am trying to use this in C5 5.5.1 with Page List Teasers 1.2 and Designer Content 3.0.2 and it isn't working. It just ends up pulling the whole Designer Content block.
There are some differences in the page_list_teasers.php file, such as there isn't a $blockforDisplay line, but I placed my code directly before the ob_start lines thinking that might work the same.
Any suggestions? Or is there a better way to do this now? Basically all I want to display out of my designer content block is the thumbnail and title.
There are some differences in the page_list_teasers.php file, such as there isn't a $blockforDisplay line, but I placed my code directly before the ob_start lines thinking that might work the same.
//Added for designercontent block } else if ($blockType == 'product') { //<--change this to the block type handle you entered in the Designer Content dashboard when creating the custom block $thumb = $blockForContent->teaserThumbnail(); echo "<img src=\'{$thumb->src}\' width=\'{$thumb->width}\' height=\'{$thumb->height}\' alt='' />"; //End added for designercontent block } else { ob_start(); $b->display(); $teaser .= ob_get_clean(); //combines ob_get_contents() and ob_end_clean() }
Any suggestions? Or is there a better way to do this now? Basically all I want to display out of my designer content block is the thumbnail and title.
I changed the code in a recent version of Page List Teasers (it is more efficient now).
Assuming your designer content block has the "teaserThumbnail()" function, you would modify your page list teaser code so instead of this:
...you have this:
Assuming your designer content block has the "teaserThumbnail()" function, you would modify your page list teaser code so instead of this:
$thumb = $blockForContent->teaserThumbnail();
...you have this:
$bi->teaserThumbnail();
I think you can do this fairly easily with some code modifications though...
First, edit your custom block's controller.php file, and find this line of code:
... and insert this new code BEFORE that line:
NOTE that you may need to change "field_1_image_fID" to the proper field name (depends on how you build your block exactly -- easiest way to find out is probably to look in the view.php file and find the field that's being used in the first <img> tag you see in that file).
ALSO note that the numbers "200" are the resize or crop width and height (respectively), and the "true" tells it to crop (change this to false if you want proportional resize instead).
Next edit this file:
...and find this chunk of code:
...and directly BEFORE that chunk of code insert this chunk of code:
I *think* that should work. Do take note of the fact that we had to modify the Page List Teaser package code so if that's ever updated in the future you will need to re-apply this patch.
-Jordan