Forums

icons not being displayed

chrissy6930 15 Mar, 2015
hi all,

I have set up a connection that lists all entries. depending on the 'type' selected a diff icon should be displayed b4 the title

in header code I have:
<?php
$app = JFactory::getApplication();
$cur_template = $app->getTemplate();
$url = JURI::root().'templates/'. $cur_template .'/images/';
?>


in body code I have:

    <div class="cf_vtitle">
      <div class="cf_vtype">
          <?php if ('Entries.type' =='1')  :
          	echo JHTML::_('image', $url.'Lightning.png','');
          elseif ('Entries.type' == '2'):
          	echo JHTML::_('image', $url.'Info.png',''); 
          elseif ('Entries.type' == '3'):
          	echo JHTML::_('image', $url.'Question.png',''); 
         endif; ?>
      </div>
      {Entries.title}
    </div>


but: while the title is being displayed the respective icon is not, only an empty div tag is visible in FF
there is no error, debugging (CC) and error reporting (system) are enabled
Model ID: Entries

could anybody pls advice?

best regards
Gabriela
GreyHead 16 Mar, 2015
Hi Gabriela,

I think that the $url you have defined is available only in the header. Try defining it as global variable in the header and the body.

Bob
chrissy6930 16 Mar, 2015
hi Bob,

I tried your suggestion by adding the snippet to the body code but there is no change to previous state to be seen.
the respective div tag is still blank in FF

best regards
Gabriela
GreyHead 16 Mar, 2015
Hi Gabriela,

If you look at the page HTML now what do you see where the link should be?

Have you tried using plain HTML rather than JHTML::_() ?

Bob
chrissy6930 17 Mar, 2015
Hi Bob,

the page html displays
<div class="cf_vtype"> </div>

and when replacing
echo JHtml::_('image', $url.'Question.png',''); 

with
?><img src="<?php echo $url.'Question.png'?>" alt="" title="question"/><?php

the page html remains the same
and there is no error either

best regards
Gabriela
chrissy6930 21 Mar, 2015
Hi Bob,

I tried changing the code to a switch but now $image returns an error (undefined variable).

switch ('Entries.type') {...}


best regards
Gabriela
chrissy6930 21 Mar, 2015
Hi Bob,

mouseover the delete link displays
javascript:deleteEntry(\

the respective snippet is:
<a href='javascript:deleteEntry(\'{$detail['uniq_id']}\')'>##DELETE##</a>

best regards
Gabriela
GreyHead 21 Mar, 2015
Hi Gabriela,

I thought that this was working a while ago?

You can't run a switch statement against a string - it needs to be a PHP variable if you want it to do anything.

The delete link just looks like a mess - I'm not sure how you have got that mixture of code.

Bob
chrissy6930 21 Mar, 2015
Hi Bob,

first off the msg with the delete link belongs to this thread:
http://www.chronoengine.com/forums/posts/f2/t99079/viewform-versus-menu-link.html

I had only tested the add button and edit links then... since the delete buttons worked on the old form I didn't test them at first.
only after my post above I did so...

on the old form the delete link was:
<a href="javascript:deleteEntry('<?php echo $detail['uniq_id'];?>')"><?php echo JText::_('DELETE'); ?></a>


and so far I couldn't get the icons to show on the connection

best regards
Gabriela
chrissy6930 23 Mar, 2015
I am still struggling trying to get this to work

using a switch with $form->data $form errors out as undefined

using this instead:
          $app = JFactory::getApplication();
          $cur_template = $app->getTemplate();
          $image_url = JURI::root()."templates/{$cur_template}/images/";
          if ('Entries.type' =='1') :
            $image = 'Lightning.png';
          elseif ('Entries.type' == '2') :
             $image = 'Info.png';
          elseif ('Entries.type' == '3') :
            $image = 'Question.png';
          endif;
          $icon= JHTML::_('image', $image_url.$image, '');
          echo $icon;


$image errors out as undefined

and the html displays the image url excluding the image name

best regards
Gabriela
GreyHead 23 Mar, 2015
Hi Gabriela,

This will always be false, you are comparing two strings:
if ('Entries.type' =='1')
Please see the example that I wrote for you in the listEntries form
  switch ( $detail['type'] ) {
    case 1:
      $image = 'Lightning.png';
      break;
    case 2:
      $image = 'Info.png';
      break;
    default:
      $image = 'Question.png';
      break;
  }
  $image= JHTML::_('image', $image_url.$image, '');
It's not clear to me where you are getting Entries.type from; most likely that should be $form->data['type']

Bob
chrissy6930 23 Mar, 2015
Hi Bob,

using a switch with $form->data['type'] returns the following errors:

Notice: Undefined variable: form in ../administrator/components/com_chronoconnectivity5/chronoconnectivity/blocks/custom.php(44) : eval()'d code on line 18

Notice: Trying to get property of non-object in ../administrator/components/com_chronoconnectivity5/chronoconnectivity/blocks/custom.php(44) : eval()'d code on line 18

Notice: Undefined variable: image in ../administrator/components/com_chronoconnectivity5/chronoconnectivity/blocks/custom.php(44) : eval()'d code on line 31

best regards
Gabriels
GreyHead 26 Mar, 2015
Answer
1 Likes
Hi Gabriela,

It's fixed. The code is similar to the ChronoForms code except that the data for each row is in $row - in this case the type is in $row['Entries']['type']

I also moved the <tbody> tags out of the Body box as you don't want them round every row; and I moved the $image_url code to the header and defined it as global so it is not repeated in every row.

Bob
This topic is locked and no more replies can be posted.