Adding classes and laying out content

Permalink Browser Info Environment
Hi there, first of all thanks for such a great tool. Although not doing what I need now I know it will once I wrap my head around it.

I was wondering how I isolate the components of an element added. For example here is what I have at the moment in my view.php

<?php defined('C5_EXECUTE') or die(_("Access Denied.")); ?>
<?php /* This block was made with Designer Content Pro. Visithttp://theblockery.com/dcp for documentation. */ ?>
         <div class="grid-container punline-wrapper"> 
                           <?php foreach ($controller->getRepeatingItems() as $item): ?>
                           <div class="grid-20 grid-parent">
                                   <ul class="punchlines">
                                           <li class="punchicon"><?php $item->btnimage->display(); ?></li>
                                                <li class="punchtitle"><?php $item->btntitle->display(); ?></li>
                                                <li class="punchlink"><?php $item->btnlink->display(); ?></li>
               </ul>
                           </div>
                                <?php endforeach; ?>
                                <div class="grid-40">
                                   <?php $item->punchlinedescription->display(); ?>
                           </div>


But what I am ultimately trying to achieve is something like this for the first li which is an image...

<li class="punchicon"><a href="#" class="light-grey-gradient"><img src="<?=$this->getThemePath()?>/img/icons/home-icons/branddevelopment.png" /></a><span class="spacer"><img src="<?=$this->getThemePath()?>/img/icons/home-icons/spacer.png" /></span></li>


Here the image SRC should be that of that of <?php $item->btnimage->display(); ?> (replicated) and <a href="#" class="light-grey-gradient"> should be <a href="#" class="light-grey-gradient"> should have the HREF from <?php $item->btnlink->display(); ?>

So basically I am just trying to isolate the bare essentials out of the code to slice into my view.php. Similar to what was possible when editing the view.php of Content Designer.

Secondly, is there any way to add in a non-repeating area? As you can see at the end of my current view.php (above) I have a item outside of the foreach loop which doesn't need to appear on each 'add new item' area. This isn't essential however I am just trying to tie areas into one editing interface/block.

Type: Discussion
Status: New
mobius2000
View Replies: View Best Answer
mobius2000 replied on at Permalink Reply
mobius2000
Ok, in looking a little deeper I discovered that the block in siteroot/blocks/xxxx is a overide of the real one found in packages/designer_content_pro/ etc etc.

So this gives me a bit more to go on now... Still not entirely sure how to get just the SRC out of the image item.
theblockery replied on at Permalink Best Answer Reply
theblockery
Hi,
I answered this question in the support forum for you, but I'm going to
repeat it here in case anyone else in the future sees this:

You can get the isolated components of any field type, as explained in the
"front-end API" section of the documentation here:
http://theblockery.com/designer-content-pro/#api...

For example, to get just the URL for your link field you can do this:

<?php echo $item->btnlink->getHref(); ?>

And to get the src of the image field you can do this:

<?php echo $item->btnimage->getImageObj()->src; ?>

Unfortunately at this time there is no way to have "non-repeating" fields
in DC Pro blocks, so the only way to achieve what you're trying to do with
the "description" is to either use a separate content block, or add that
field to every repeating item but tell your users to leave it blank for all
but one of them. I know this is not ideal, and we are planning to add
"non-repeating" fields in the future (but it's still a ways off so it won't
be ready very soon).

Let me know if you have any other questions, and thanks for purchasing
Designer Content Pro.

-Jordan

On Thursday, November 28, 2013, concrete5 Community wrote:
mobius2000 replied on at Permalink Reply
mobius2000
Thank you very much, I knew it would be straight forward by lack of PHP knowledge stood in the way of understanding the front-end API docs clearly enough.

Entirely my fault and I can confirm this block does work amazingly well and fills a void in C5 experienced by designers who have limited (but the desire) to tinker with code and custom elements.

Thank you Jordan.
theblockery replied on at Permalink Reply
theblockery
You're very welcome! I understand how challenging it can be to wrap your head around the PHP code when coming from more of a design background, so please don't feel bad about it -- this is all part of the learning process and I'm happy to help in any way I can.

Best,
Jordan
mobius2000 replied on at Permalink Reply
mobius2000
Just adding a correction here for prosperity from theblockery... The image SRC code is:
<?php echo $item->btnimage->getImageObj()->src; ?>

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.