SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jun 2012
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    display field list with icon

    Currently I am trying to reconstruct the module code by adding Icons next to each field in the listing. This is the code below.

    <?php
    if (empty($item->webpage)) :
    ?>

    <td class="peoplename"><?php echo $item->name; ?></td>
    <td class="peopleemailto"><a href="mailto?php echo $item->email_to; ?>"><?php echo $item->email_to; ?></a></td>
    <td class="peopletelephone"><?php echo $item->telephone; ?></td>
    <td class="peoplewebpage"><a href="<?php echo JRoute::_(''); ?>"><img src="/images/powered_by.png"></a></td>

    {?php endif; ?>

    My objective is to display an icon/image next to each field list that has a webpage only. Otherwise it display only the list without image.

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    I presume you want the opposite of what you showed us then, that if a webpage is set, show the <td> contents? If so try either of these 2 alterations to your first line:
    PHP Code:
    if ($item->webpage) : 
    PHP Code:
    if( isset($item->webpage)) : 

  3. #3
    SitePoint Member
    Join Date
    Jun 2012
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes I want to display an icon next to each name field if they have an extended website where the field name is "webpage".

    <?php
    if (isset($item->webpage)) :
    ?>

    <td class="peoplename"><?php echo $item->name; ?></td>
    <td class="peopleemailto"><a href="mailto?php echo $item->email_to; ?>"><?php echo $item->email_to; ?></a></td>
    <td class="peopletelephone"><?php echo $item->telephone; ?></td>
    <?php
    else
    ?>
    <td class="peoplename"><?php echo $item->name; ?></td>
    <td class="peopleemailto"><a href="mailto?php echo $item->email_to; ?>"><?php echo $item->email_to; ?></a></td>
    <td class="peopletelephone"><?php echo $item->telephone; ?></td>
    <td class="peoplewebpage"><a href="<?php echo JRoute::_(''); ?>"><img src="/images/powered_by.png"></a></td>
    <?php endif; ?>

  4. #4
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Isolate that which changes.

    If name, mail, phone are common to both cases then can you not get on and print them anyway?

    PHP Code:

    <td class="peoplename"><?php echo $item->name?></td>
    <td class="peopleemailto"><a href="mailto?php echo $item->email_to; ?>"><?php echo $item->email_to?></a></td>
    <td class="peopletelephone"><?php echo $item->telephone?></td>

    <!-- only have this one condition -->

    <?php if (isset($item->webpage)) : ?>
    <td class="peoplewebpage"><a href="<?php echo JRoute::_(''); ?>"><img src="/images/powered_by.png"></a></td>
    <?php endif; ?>
    Top tip: To format code on here, wrap your php code in the tags [ php ] [ /php ] (without the spaces)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •