Is it possible to add a link to the image field?

Permalink Browser Info Environment
Hi, I've just installed Designer Content Pro, and found there is no possibility to put a link to the image field as free version of Designer Content. I'm not a programmer, so I have no idea how it works.
Could you let me know?
At this moment the part looks like this.

<div class="logo">
<?php $item->logo->display(); ?>
</div>

I really appreciate your help.
Thanks.

Type: Discussion
Status: New
ahncho
View Replies:
theblockery replied on at Permalink Reply
theblockery
Hi,
Thanks for purchasing Designer Content Pro. It is a bit different that the free version, but it allows for a lot more flexibility. If you want an image that links somewhere, you need 2 separate fields (1 image field and 1 link field). Then in your view.php file, you could do something like this:
<?php foreach ($controller->getRepeatingItems() as $item) { ?>
  <div class="logo">
    <a href="<?php echo $item->link->getHref(); ?>">
      <?php $item->logo->display(); ?>
    </a>
  </div>
<?php endforeach; ?>

Note that in this example, the handle of the link field is "link" (but it could be anything you want, just depends on what you set for the blocktype via the Designer Content Pro dashboard page).

There is full documentation on all the available functions of each field type here:
http://theblockery.com/designer-content-pro/#api...

If you're still stuck, I am more than happy to keep helping you. Some people find it helpful to come up with all their markup first (just the HTML and CSS), then you could post that here and I could respond with the PHP code that you need to make it work with Designer Content Pro.

Let me know how it goes.

-Jordan
ahncho replied on at Permalink Reply
ahncho
Thank you for your rapid answer.
According as your instruction I made one link field separately.
It was a little bit tricky to me because the sample code says:
<?php $item->link->display(); ?>


I changed the part "display" into "getHref" and it looks like this and it works:
<div class="logo">
 <a href="<?php $item->link->getHref(); ?>">
<?php $item->logo->display(); ?>
</a>
</div>


Yes, as you say Designer Content Pro seems to offer more flexiblity, although you need a bit knowledge of programming. But it's an exciting tool indeed. Thank you for your support!
theblockery replied on at Permalink Reply
theblockery
Glad you got it working. Please note that in the code you posted, you need to "echo" the href... so the 2nd line should be this:
<a href="<?php echo $item->link->getHref(); ?>">


The reason you must do this is because the "display" function automatically "echo"'s the field, but "getHref" only returns the url as a string so you must echo it yourself.

I know it's a bit confusing, thanks for sticking with it. And please let me know if there's anything else I can help you with in the future.

Thanks,
Jordan

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.