category name raw code?

  • Posts: 5
  • Thank you received: 0
13 years 10 months ago #8956

Hi, i want the raw php coding to show category name that ni want to put in listing_div.php on product page, i know that i can use the button to enable the title, but im heavily modifying the code and im stuck on this tiny piece of coding

ive tested this:
<?php echo $this->params->get('main_div_name').$this->category_selected; ?>

but i only get the id, i want to chage it so it shows the name

anyone?

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

  • Posts: 83024
  • Thank you received: 13403
  • MODERATOR
13 years 10 months ago #8958

You need to load the category data if you want its name because it's not loaded on that page:

$categoryClass = hikashop::get('class.category');
$category = $categoryClass->get(JRequest::getVar('category_pathway'));

echo @$category->category_name;

(please remember that you should avoid to modify the view files directly and use the menu Display->Views instead which will save your modifications in your template's view override folder and allow you to update HikaShop without loosing your modifications)

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

  • Posts: 5
  • Thank you received: 0
13 years 10 months ago #8963

nicolas wrote:

You need to load the category data if you want its name because it's not loaded on that page:

$categoryClass = hikashop::get('class.category');
$category = $categoryClass->get(JRequest::getVar('category_pathway'));

echo @$category->category_name;

(please remember that you should avoid to modify the view files directly and use the menu Display->Views instead which will save your modifications in your template's view override folder and allow you to update HikaShop without loosing your modifications)


it doesnt seem to work at all, i tried to insert the code at various places but without any results, it comes out blank, frontend source code shows nothing either

have i missed something?

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

  • Posts: 83024
  • Thank you received: 13403
  • MODERATOR
13 years 10 months ago #8966

What is the link of our product page ? Do you have a category_pathway in the parameters of that link ?

Could you copy/paste the modification you did ?

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

  • Posts: 5
  • Thank you received: 0
13 years 10 months ago #8974

nicolas wrote:

What is the link of our product page ? Do you have a category_pathway in the parameters of that link ?

Could you copy/paste the modification you did ?


from listing_div.php in product folder


<?php } ?>
<div class="hikashop_products" style="clear:both">

<?php $class = hikashop::get('class.category');
$category = $class->get(JRequest::getVar('category_name'));
?>
<h1> Tillgängliga delar från <?php echo $category->category_name; ?></h1>
<ul class="hikashop_product_list">
<?php
$columns = $this->params->get('columns');
$height = (int)(30/$columns)-1;
$current_column = 1;


if(!empty($this->rows)){
foreach($this->rows as $row){
?>
<div class="hikashop_product" style="width:<?php echo $width;?>%;">
<div class="hikashop_container">
<div class="hikashop_subcontainer"><h4>
<li class="hikashop_product_list_item" style="float:left;width:<?php echo $width;?>%;"><?php
$this->row =& $row;
$this->setLayout('listing_'.$this->params->get('div_item_layout_type'));
echo $row->product_name;

?></li></h4>

</div>
</div>
</div>
<?php if($current_column>=$columns){ ?>
<div style="clear:both"></div>
<?php
$current_column=0;
}
$current_column++;
}
}
?></ul>
</div>

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

  • Posts: 83024
  • Thank you received: 13403
  • MODERATOR
13 years 10 months ago #8977

You wrote $category = $class->get(JRequest::getVar('category_name'));
instead of $category = $class->get(JRequest::getVar('category_pathway'));

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

  • Posts: 5
  • Thank you received: 0
13 years 10 months ago #8979

yeah it didnt work so i tried to modify the code to see if something happened
Changed back to "category_pathway" but i still have the same problem

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

  • Posts: 83024
  • Thank you received: 13403
  • MODERATOR
13 years 10 months ago #8981

What is the link of our product page ? Do you have a category_pathway in the parameters of that link ?

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

  • Posts: 5
  • Thank you received: 0
13 years 10 months ago #8989

hikashop::completeLink('category&task=listing&cid='.$child->category_id.'&name='.$child->alias.$this->menu_id);

i think this is it, i dont think i have any parameters for category_pathway

<?php
$category_pathway = hikashop::completeLink('category&task=listing&cid='.$child->category_id.'&name='.$child->alias.$this->menu_id);
$categoryClass = hikashop::get('class.category');
$category = $categoryClass->get(JRequest::getVar('category_pathway')); ?>

tried to insert this piece of coding but still no luck

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

  • Posts: 83024
  • Thank you received: 13403
  • MODERATOR
13 years 10 months ago #8991

Wait. You said that you wanted to display the category name on the product page. So I gave you the code for that.
But now you're pasting code which is for the listing of products...
If you want to display the category name on the listing of products, you should be able to do that by just turning off the option "Use menu name instead of category name for the title" in your menu's options...

If you want to do it with code in the view, you can use that:
echo $this->element->category_name;

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

  • Posts: 52
  • Thank you received: 0
13 years 9 months ago #11466

nicolas wrote:

If you want to do it with code in the view, you can use that:
echo $this->element->category_name;


very helpful.

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

  • Posts: 52
  • Thank you received: 0
13 years 9 months ago #11477

is there some similar code for parent_category_name | category_name by any chance?

For example I have Parent Category "Soda" then Category "Cherry". Well that code just returns Cherry, which could also be other categories ("Fruit" for example). If it returned Soda > Cherry I would prefer that if possible. thanks for any help.

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

  • Posts: 83024
  • Thank you received: 13403
  • MODERATOR
13 years 9 months ago #11478

Parent categories data is not available in the view.
But I must ask, if you want the display exactly the same thing as the breadcrumb module, why not just use the breacrumb module ?

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

  • Posts: 52
  • Thank you received: 0
13 years 9 months ago #11479

well I was preferring to make it as a h1 (not linkable) but may go the breadcrumb route. I am sort of styling as I edit 700 products so my focus is lacking also. =x

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

  • Posts: 8
  • Thank you received: 0
11 years 1 month ago #129898

I would add to the discussion because I have the same problem but I can not get on top,
I need to show the name of category in the product page and in an article with products. Can you help me? I tried to include all relevant codes imaginable found in the forum but the result is always the same div/h1 empty! the link is

/it/component/hikashop/product/108-controluce.html
version of hikashop 2.2.1
joomla 3.1

please help me :(

thank you

Attachments:

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

  • Posts: 83024
  • Thank you received: 13403
  • MODERATOR
11 years 1 month ago #129962

Hi,

Here is the modification to do for what you want:
www.hikashop.com/forum/4-how-to/64957-ca...cts-pages.html#65212

The following user(s) said Thank You: marius1234

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

  • Posts: 8
  • Thank you received: 0
11 years 1 month ago #129993

Thank you,
this evening I will make the changes and i let you know

but what file I have to change for add code for product in the article?

thank you for your reply

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

  • Posts: 12953
  • Thank you received: 1778
11 years 1 month ago #130011

Hi,
What do you exactly mean by "in the article", a Joomla article ? if that's the case, you'll have to directly edit the code of the Hikashop product TAG translation plugin.

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

  • Posts: 8
  • Thank you received: 0
11 years 1 month ago #130105

Ok thank you, but how to modify this plugin? what is the path?
thank you

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

  • Posts: 13201
  • Thank you received: 2322
11 years 1 month ago #130161

The file to edit is:
"plugins\system\hikashopproducttag\hikashopproducttag.php"

The following user(s) said Thank You: marius1234

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

Time to create page: 0.125 seconds
Powered by Kunena Forum