Download & Extend

How to use efficient phpcode in a code field

Project:Node displays
Version:6.x-2.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

Hi,
Great module!
How can I change a with taxonomy terms?
I want to have the following info which I want to integrate in the node_display taxonomy:

<?php if ($terms): ?>
    <div class="terms clear-both"><div class="terms-inner">
      <?php print t('Tags') . '&#58; ' . $terms; ?>
    </div></div>
  <?php endif;?>

Thanks a lot in advance for your reply!
greetings,
Martijn

Comments

#1

Status:active» postponed (maintainer needs more info)

I'm not exactly sure what you mean ? What do you want to do exactly ? Terms are available in the node displays module, so you shouldn't have the need anymore of the $terms variable normally.

#2

Hi
I am sorry if I was not clear.
I want to use the

<div class="terms-inner"> so theming looks nice.

greetings, Martijn

#3

Ah, you can just define styles in admin/build/ds/layout/styles and use those styles. Those styles will be available to add on any field you like in the interface as an extra class.

#4

I got that, and how to imitate this behaviour (2 divs..with a ul class)? Is that also possible please?

<div class="terms clear-both"><div class="terms-inner">
      Labels&#58; <ul class="links inline"

#5

Well you could create a fieldgroup, render it as a simple div, give it the right classes and nest the terms underneath it.

#6

Poehh..don't know yet how to do this..
you mean create a fieldgroep of terms render, or links inline, the ul?

#7

Hi,

if you really want custom wrappers around your fields, I guess the best solution for you would be to create a new code field under display suite > node displays > fields. You will have to write some php code which will be quite similar to your code above.

#8

Status:postponed (maintainer needs more info)» closed (fixed)

#9

Hi Jive, Could you show the code for this case in php please?
Thanks a lot in advance.
greetings, Martijn

#10

Status:closed (fixed)» active

Hi Jive,

Set it to active, because the php code I try to put in display suite > node displays > fields doesn't show up making a new code field.
The phpcode is:

<?php if ($terms): ?>
    <div class="terms clear-both"><div class="terms-inner">
      <?php print t('Tags') . '&#58; ' . $terms; ?>
    </div></div>
  <?php endif;?>

What do I do wrong please?
Thanks again for helping me. Greetings, Martijn

#11

Title:How to change a <div>» How to use efficient phpcode in a code field
Status:active» needs review

Hi Jive,

Tried some things, and this is working. But is it the most efficient method?

<div class="terms clear-both"><div class="terms-inner">
<?php
           
print t('Tags') . '&#58; ';
            foreach (
$object->taxonomy as $term) {
              print
"<a href=\"".drupal_get_path_alias(taxonomy_term_path($term))."\">$term->name</a>" . " , ";
           }
?>

</div></div>

I am not getting it to work with tokens..[term] and [termalias]

Thanks a lot for your review.

greetings,
Martijn

#12

Status:needs review» closed (fixed)

@summit

that's pretty much the way you'd want to do that. However, with some clever CSS'ing, you can mimic the styling of the original though.

nobody click here