View template example - Manual Nav with Combo link field

Permalink Browser Info Environment
Hi DCP fans, I share my view template from my work.

<?php defined('C5_EXECUTE') or die(_("Access Denied.")); ?>
<?php /* This block was made with Designer Content Pro. Visithttp://theblockery.com/dcp for documentation. */ ?>
<?php
/**
 * link: Link Field
 * css_class: Textbox field
 */
// Get current page object
$current = Page::getCurrentPage();
// Get repeating items
$items = $controller->getRepeatingItems();
// Check if items exist
if (count($items) > 0) : ?>
<nav class="dcp-manual-nav" role="navigation">
   <ul>


To improve this template more designer friendly, we need $item->link->isSelected() and $item->link->isPathSelected() API in DcpFieldDisplay_Link class. I expect this.

Type: Discussion
Status: New
hissy
View Replies: View Best Answer
theblockery replied on at Permalink Best Answer Reply
theblockery
Thanks for posting this. Here is a more simplified version of that code, which uses the page paths for comparison (it cuts down on a lot of logic this way):
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); ?>
<?php /* This block was made with Designer Content Pro. Visithttp://theblockery.com/dcp for documentation. */ ?>
<?php
/**
 * link: Link Field
 * css_class: Textbox field
 */
// Get current page path
$current_path = Page::getCurrentPage()->getCollectionPath();
// Get repeating items
$items = $controller->getRepeatingItems();
// Check if items exist
if (count($items) > 0) : ?>
<nav class="dcp-manual-nav" role="navigation">
   <ul>


And I think your suggestion for "isSelected" and "isPathSelected" is a good one -- I will consider adding this to the next version.

-Jordan
hissy replied on at Permalink Reply
hissy
Thanks to suggestion about simplified version!

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.