Keyword

php code to display k2 category block in joomla templat

  • left19
  • left19's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 8 months ago #92896 by left19
i know that i can set a module in joomla to go to a menu item, the seciton that my k2 is in. But that won't work. Becasue it puts that module code on all the k2 pages under it as well.. I just want to put the module onto the category main page only.

1. is this possible using a module liked to a menu item but not pages beneath that item?

2. can anyone give me the php code that i can insert into my joomla tempate (japurity) that will say

     if this is the k2 category main page (k2-category1) do this, else do nothing.

 

I was thinking of possibly using this code to pull the cateogry block from the k2 area and put it into the joomla area????

 

<div class="itemListCategoriesBlock">        <?php if(isset($this->category) && ( $this->params->get('catImage') || $this->params->get('catTitle') || $this->params->get('catDescription') || $this->category->event->K2CategoryDisplay )): ?>        <!-- Category block -->        <div class="itemListCategory">            <?php if(isset($this->addLink)): ?>            <!-- Item add link -->            <span class="catItemAddLink">                <a class="modal" rel="{handler:'iframe',size:{x:990,y:650}}" href="<?php echo $this->addLink; ?>">                    <?php echo JText::_('Add a new item in this category'); ?>                </a>            </span>            <?php endif; ?>            <?php if($this->params->get('catImage') && $this->category->image): ?>            <!-- Category image -->            <img alt="<?php echo $this->category->name; ?>" src="<?php echo $this->category->image; ?>" style="width:<?php echo $this->params->get('catImageWidth'); ?>px; height:auto;" />            <?php endif; ?>            <?php if($this->params->get('catTitle')): ?>            <!-- Category title -->            <h2><?php echo $this->category->name; ?><?php if($this->params->get('catTitleItemCounter')) echo ' ('.$this->pagination->total.')'; ?></h2>            <?php endif; ?>            <?php if($this->params->get('catDescription')): ?>            <!-- Category description -->            <p><?php echo $this->category->description; ?></p>            <?php endif; ?>            <!-- K2 Plugins: K2CategoryDisplay -->            <?php echo $this->category->event->K2CategoryDisplay; ?>            <div class="clr"></div>        </div>        <?php endif; ?>        <?php if($this->params->get('subCategories') && isset($this->subCategories) && count($this->subCategories)): ?>        <!-- Subcategories -->        <div class="itemListSubCategories">            <h3><?php echo JText::_('Children categories'); ?></h3>            <?php foreach($this->subCategories as $key=>$subCategory): ?>            <?php            // Define a CSS class for the last container on each row            if( (($key+1)%($this->params->get('subCatColumns'))==0) || count($this->subCategories)<$this->params->get('subCatColumns') )                $lastContainer= ' subCategoryContainerLast';            else                $lastContainer='';            ?>            <div class="subCategoryContainer<?php echo $lastContainer; ?>"<?php echo (count($this->subCategories)==1) ? '' : ' style="width:'.number_format(100/$this->params->get('subCatColumns'), 1).'%;"'; ?>>                <div class="subCategory">                    <?php if($this->params->get('subCatImage') && $subCategory->image): ?>                    <!-- Subcategory image -->                    <a class="subCategoryImage" href="<?php echo $subCategory->link; ?>">                        <img alt="<?php echo $subCategory->name; ?>" src="<?php echo $subCategory->image; ?>" />                    </a>                    <?php endif; ?>                    <?php if($this->params->get('subCatTitle')): ?>                    <!-- Subcategory title -->                    <h2>                        <a href="<?php echo $subCategory->link; ?>">                            <?php echo $subCategory->name; ?><?php if($this->params->get('subCatTitleItemCounter')) echo ' ('.$subCategory->numOfItems.')'; ?>                        </a>                    </h2>                    <?php endif; ?>                    <?php if($this->params->get('subCatDescription')): ?>                    <!-- Subcategory description -->                    <p><?php echo $subCategory->description; ?></p>                    <?php endif; ?>                    <!-- Subcategory more... -->                    <a class="subCategoryMore" href="<?php echo $subCategory->link; ?>">                        <?php echo JText::_('View items...'); ?>                    </a>                    <div class="clr"></div>                </div>            </div>            <?php if(($key+1)%($this->params->get('subCatColumns'))==0): ?>            <div class="clr"></div>            <?php endif; ?>            <?php endforeach; ?>            <div class="clr"></div>        </div>        <?php endif; ?>    </div>

 

 

 

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

  • left19
  • left19's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 8 months ago #92897 by left19
i think you have all k2 though, and I have joomla articles and k2 articles in some of my sections. ??

anyway I figured out using jumi and a call that says if the url matches this, then show this, else, do nothing. and that is working to pull in an image (for now) onto the category main page. The only problem with that is that its code and I don't know how to tell jumi to pull in a custom module if that is true. Anyway, it's working okay for what I need now as long as no one ups the anty and wants something more. :)

Thanks for your response.

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

  • left19
  • left19's Avatar Topic Author
  • Offline
  • Junior Member
More
13 years 8 months ago #92898 by left19
Yes, i think that is basically what I'm doing using JUMI, it's like sorcerer. Thanks for your help.

Kevin said:
Well, I still might be able to help, I am pulling in all kinds of PHP on that site. The stores have items, they are pulling in custom php code. Most k2 items have custom php code added to the article. There are plugins for this.

I am using DirectPHP and Sourcerer.

What I do is create a php file then do an include ('');

 

Sourcerer is

{source}<?phpinclude ('shop/office_max_page.php');?>{/source}

 

which of course loads the office max items

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


Powered by Kunena Forum