Keyword

[SOLVED] category item image

  • antonio maarawi
  • antonio maarawi's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 11 months ago #119812 by antonio maarawi
[SOLVED] category item image was created by antonio maarawi
Dear sir,
how can i make k2 items in category list to get the category image when there is no image associated to it.
to prevent being blank.

Please Log in or Create an account to join the conversation.

  • antonio maarawi
  • antonio maarawi's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 10 months ago #119813 by antonio maarawi
Replied by antonio maarawi on topic Re: category item image
No body home!

Please Log in or Create an account to join the conversation.

More
10 years 10 months ago - 10 years 10 months ago #119814 by Lefteris
Replied by Lefteris on topic Re: category item image
First you need to create a K2 template override if you are not using already. Read here getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates how the overrides work and how you can set them up.

Then you will have to edit category_item.php file and replace the following block of code
<?php if($this->item->params->get('catItemImage') && !empty($this->item->image)): ?>
          <!-- Item Image -->
          <div class="catItemImageBlock">
                  <span class="catItemImage">
                    <a href="<?php echo $this->item->link; ?>" title="<?php if(!empty($this->item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>">
                        <img src="<?php echo $this->item->image; ?>" alt="<?php if(!empty($this->item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>" style="width:<?php echo $this->item->imageWidth; ?>px; height:auto;" />
                    </a>
                </span>           
          </div>
          <?php endif; ?>

with this one
<?php if($this->item->params->get('catItemImage') && !empty($this->item->image)): ?>
          <!-- Item Image -->
          <div class="catItemImageBlock">
                  <span class="catItemImage">
                    <a href="<?php echo $this->item->link; ?>" title="<?php if(!empty($this->item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>">
                        <img src="<?php echo $this->item->image; ?>" alt="<?php if(!empty($this->item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>" style="width:<?php echo $this->item->imageWidth; ?>px; height:auto;" />
                    </a>
                  </span>           
          </div>
          <?php elseif($this->category->image): ?>    
    <!-- Category Image -->
    <div class="catItemImageBlock">
      <span class="catItemImage">
        <a href="<?php echo $this->item->link; ?>" title="<?php if(!empty($this->item->image_caption)) echo K2HelperUtilities::cleanHtml($this->item->image_caption); else echo K2HelperUtilities::cleanHtml($this->item->title); ?>">         
          <img alt="<?php echo K2HelperUtilities::cleanHtml($this->category->name); ?>" src="<?php echo $this->category->image; ?>" style="width:<?php echo $this->params->get('catImageWidth'); ?>px; height:auto;" />
        </a>
      </span>      
    </div> 
    <?php endif; ?>

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • antonio maarawi
  • antonio maarawi's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 10 months ago #119815 by antonio maarawi
Replied by antonio maarawi on topic Re: category item image
Thank you so much,
does this code work for tags view too? item tags which doesn't have picture!
thank you again

Please Log in or Create an account to join the conversation.

  • Yiota
  • Yiota's Avatar
  • Visitor
10 years 10 months ago #119816 by Yiota
Replied by Yiota on topic Re: category item image
For the tags you need to alter the code a bit.
Try with the following:
<?php if($item->params->get('tagItemImage',1) && !empty($item->imageGeneric)): ?>
			  <!-- Item Image -->
			  <div class="tagItemImageBlock">
				  <span class="tagItemImage">
				    <a href="<?php echo $item->link; ?>" title="<?php if(!empty($item->image_caption)) echo K2HelperUtilities::cleanHtml($item->image_caption); else echo K2HelperUtilities::cleanHtml($item->title); ?>">
				    	<img src="<?php echo $item->imageGeneric; ?>" alt="<?php if(!empty($item->image_caption)) echo K2HelperUtilities::cleanHtml($item->image_caption); else echo K2HelperUtilities::cleanHtml($item->title); ?>" style="width:<?php echo $item->params->get('itemImageGeneric'); ?>px; height:auto;" />
				    </a>
				  </span>
				  <div class="clr"></div>
			  </div>
			  <?php elseif($item->category->image): ?>    
        <!-- Category Image -->
        <div class="tagItemImageBlock">
          <span class="tagItemImage">
            <a href="<?php echo $item->link; ?>" title="<?php if(!empty($item->image_caption)) echo K2HelperUtilities::cleanHtml($item->image_caption); else echo K2HelperUtilities::cleanHtml($item->title); ?>">         
              <img alt="<?php echo K2HelperUtilities::cleanHtml($item->category->name); ?>" src="<?php echo JURI::base().'media/k2/categories/'.$item->category->image; ?>" />
            </a>
          </span>      
        </div>         
        <?php endif; ?>

Please Log in or Create an account to join the conversation.

  • antonio maarawi
  • antonio maarawi's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 10 months ago #119817 by antonio maarawi
Replied by antonio maarawi on topic Re: category item image
no i didn't work for the tags:

www.elmarada.org/tag/البطريرك-لحام

Please Log in or Create an account to join the conversation.

  • Yiota
  • Yiota's Avatar
  • Visitor
10 years 10 months ago #119818 by Yiota
Replied by Yiota on topic Re: category item image
Is it possible this category doesn't have an image?

Please Log in or Create an account to join the conversation.

  • antonio maarawi
  • antonio maarawi's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 10 months ago #119819 by antonio maarawi
Replied by antonio maarawi on topic Re: category item image
no it does have, and also tried another tags in another cateogry

Please Log in or Create an account to join the conversation.

  • Yiota
  • Yiota's Avatar
  • Visitor
10 years 10 months ago #119820 by Yiota
Replied by Yiota on topic Re: category item image
Could you make a var_dump to $item->category->image to see whether it gets the image or not?

Please Log in or Create an account to join the conversation.

  • antonio maarawi
  • antonio maarawi's Avatar Topic Author
  • Offline
  • Junior Member
More
10 years 10 months ago #119821 by antonio maarawi
Replied by antonio maarawi on topic Re: category item image
can you tell me how please?

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum