echo image

Permalink
Could someone please help me with the following. I have a certain piece of code in a view.php of a block that say's

$picture = $this->controller->getPicture();
echo "<h2>{$title}</h2>";
if ($picture) {
   echo $html->image($picture->getURL());
}


The function getPicture:

function getPicture() {
      if ($this->fIDpicture > 0) {
         return File::getByID($this->fIDpicture);
      }
      return null;
   }


Now what I want to do is to show the image that is being called in this certain piece of view.php above, in another block. Thus calling it from another view.php file.

My skills are limited at the moment when it comes to block editing etc. so please bare with me. I'm learning Concrete with the Packt Concrete 5 Beginners Guide. The pieces of code that I'm showing are obtained from that book.

Thanks in advance!

GreyhorseDesign
 
jordanlev replied on at Permalink Reply
jordanlev
When you say "another view.php", do you mean that you want to create a custom template for the block, or that you want to show this block on another page (from another kind of block)?

If the latter, it depends on where this block is. Is it on another page, or is it in the "global scrapbook" (if using Concrete5.4.2 or below), or in a "Stack" (if using Concrete5.5.0 or above)? Or is it not one specific block but could be one of several blocks that you want the user to choose somehow?

Also, this might not be the best approach to use -- it can be handy sometimes but often there's a simpler solution to showing content from one page to another (usually involving a custom template for the Page List block).

If you can provide these details someone can surely offer specific advice.
GreyhorseDesign replied on at Permalink Reply
GreyhorseDesign
Thank you for your reaction. Maybe I should clarify myself a little more by telling in short what the blocks are about because the answer was not quite what I expected.
Further on I will try to reformulate my question.

So, first off, the blocks..

1) The first block is a product information block. With this block i'm able to create a simple product page. I can add a product title, an illustration and a product description.

I can also store this productpage into a category (there are a number of categories) which is usefull for the second block becasue it is linked with the first one.

2) The second block produces an overview (a list) of all the products that were added with the product information block (1) in a certain category.
So by selecting a category with the second block a list is created of all the product pages that were created with the first block.

Some information of the first block is than reused to show in the items of the list.

The view.php of the first blocks is build up like:

<div class="product-information">
<?php
$html = Loader::helper('html');
$picture = 
$this->controller->getPicture();
echo "<h2>{$title}</h2>";
if ($picture) {
   echo 
$html->image($picture->getURL());
}
echo "<p>{$description}</p>";
?>
</div>


The view.php of the second block is build up like following:

<?php
defined('C5_EXECUTE') or die(_("Access Denied."));
$nh = Loader::helper('navigation');
$products = $this->controller->getProducts();
foreach ($products as $product) {
   $pageLink = $nh->getLinkToCollection($product->getOriginalCollection());
   echo "<h2>{$product->instance->title}</h2>";
   echo "<a href=\"{$pageLink}\">more...</a>";
   echo "<hr/>";
}
?>


Where the following rule obviously recalls the title that was given in the first block:

echo "<h2>{$product->instance->title}</h2>";


Now what I am trying to achieve next is to recall the photo that was added in the first block. Just like the title that was recalled from the first block

You can see the snippet of that script written in my original question.

I've created the blocks with the usage the information that is provided in the book from Packt - Concrete 5 Beginners Guide so maybe someone recognizes this?
geekeboy replied on at Permalink Reply
Looking for the same here

Thought the answer may be in the next section 'jqzoom'

Completely lost!!!!