Add tab on product page

  • Posts: 78
  • Thank you received: 3
9 years 4 months ago #225560

Yep, that did the trick. Thank you. So how do I move the last two fields (the media fields) from the Specifications tab to the new tab? I only want those two in that tab and not appearing at all in the Specifications tab.

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

  • Posts: 13201
  • Thank you received: 2322
9 years 3 months ago #225592

Hi,

You have to edit the view "product / show_block_custom_main" and in the foreach add a PHP check in order to not display the desired fields, a check like:

// right after the foreach line
if(in_array($fieldName,array('CUSTOM_FIELD1','CUSTOM_FIELD2')) continue;
That way it will not be displayed in the specification tab, and to display it in the new tab, you have to edit the view "product / show_tabular" and in the div add code like:
echo $this->element->CUSTOM_FIELD1;
echo $this->element->CUSTOM_FIELD2;

Where of course "CUSTOM_FIELD1" and "CUSTOM_FIELD2" must be replaced by the custom field column name.

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

  • Posts: 78
  • Thank you received: 3
9 years 3 months ago #225652

I put this:

if(in_array($fieldName,array('sm_preview','sm_media')) continue;
right after
foreach ($this->fields as $fieldName => $oneExtraField) {
and before (and after)
$value = '';

and it broke the website.

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

  • Posts: 78
  • Thank you received: 3
9 years 3 months ago #225655

Also, one of those echo lines is suppose to be restricted by group. It new shows up. How do I make it only seen by certain groups?

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

  • Posts: 26227
  • Thank you received: 4035
  • MODERATOR
9 years 3 months ago #225653

Hi,

If you have PHP errors ; please take a look at your PHP error log in order to have more details about your issue.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 78
  • Thank you received: 3
9 years 3 months ago #225760

After turning on all the error reporting this is what was reported:

Parse error: syntax error, unexpected 'continue' (T_CONTINUE) in /com_hikashop/product/show_tabular.php on line 33

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

  • Posts: 13201
  • Thank you received: 2322
9 years 3 months ago #225772

Hi,

My bad, there is a missing parentheses in the given code, you have to use this one instead:

if(in_array($fieldName,array('sm_preview','sm_media'))) continue;

To restrict on a user group, you have to add check on the user like that:
	$user = JFactory::getUser();
	$groups = isset($user->groups) ? $user->groups : array();
	if(in_array('X',$groups)){
		
	}
Where X is the group id you want to apply the restriction.

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

  • Posts: 78
  • Thank you received: 3
9 years 3 months ago #225838

if(in_array($fieldName,array('sm_preview','sm_media'))) continue;

It doesn't cause any errors, but it also doesn't remove the fields from the Specifications tab.
$user = JFactory::getUser();
	$groups = isset($user->groups) ? $user->groups : array();
	if(in_array('X',$groups)){
		
	}

So how would you do multiple groups?

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

  • Posts: 13201
  • Thank you received: 2322
9 years 3 months ago #225867

Hi,

1/ I just tried on my local to be sure, and the code:

if(in_array($fieldName,array('sm_preview','sm_media'))) continue;
Added tight after the code:
foreach ($this->fields as $fieldName => $oneExtraField) {
In the view:

product / show_block_custom_main

Correctly remove the display of the custom product fields from the specifications tab.

So please check that the name you use is the same than the table name in the custom field settings. Another thing, are we talking about custom product fields or custom item fields ? If it is custom item fields so the view to edit is:

product / show_block_custom_item


2/ To check if one of the user groups match to one of the set groups you can use the code:
$user = JFactory::getUser();
$groups = isset($user->groups) ? $user->groups : array();
if(in_array(array('X','Y'),$groups)){
		
}

Please note that these modifications are customizations, and we generally don't support this kind of requests.
If you are not a developer, you can post your customization request in the commercial jobs section of this forum :)

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

  • Posts: 87
  • Thank you received: 5
  • Hikashop Business
9 years 3 months ago #225943

If you can live without the Hikashop standard Specification TAB you could just remove / suppress it in:

Display → Views → Select (the correct) Template → Select Product → show_tabular

and replace:

<?php if($hide_specs == 0){ ?>

by

<?php if($hide_specs == 1){ ?>

So just change 0 to 1 you should find this line of code twice around line 20 and 260

It's a better solution then the CSS hide option(s) since Hikashop will not display or send any unneeded information and an update will not break or overwrite it.

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

  • Posts: 78
  • Thank you received: 3
9 years 3 months ago #225945

I appreciate all your help. So I got the first part working. The last two custom fields are not in the Specifications Tab. Thank you.

Last question on this subject.
What am I doing wrong?

<?php $user = JFactory::getUser();
$groups = isset($user->groups) ? $user->groups : array();
if(in_array(array('7','8','10','11'),$groups)){
		echo $this->element->sm_media;
} else {echo $this->element->sm_preview;}?>	

What I want it to do is if the group is one of the above listed, then it displays the sm_media field. If not, then do the sm_preview field. It's just displaying the the sm_preview field.

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

  • Posts: 138
  • Thank you received: 4
9 years 3 months ago #225958

hi,
How do we put the related products in tabular?


Joomla Developer | am.ebrahimzadeh[at]gmail.com

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

  • Posts: 13201
  • Thank you received: 2322
9 years 3 months ago #226035

Hi,

@webhelpus: What is the type of your custom fields ? If it is product custom fields, so using your code should be working.
If it is "Item" fields, so you need to use code as in the "show_block_custom_item" view to display the fields.

@aminweb: To display related products in a tab, you can edit the view "product / show_tabular" and add code like:

<?php echo JHTML::_('content.prepare','{loadposition XX}'); ?>
The {loadposition XX} code is a Joomla feature, this allow to have a module in any content, so that way you can setup a related module and display it where you want. docs.joomla.org/How_do_you_put_a_module_inside_an_article%3F

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

  • Posts: 78
  • Thank you received: 3
9 years 3 months ago #226147

Both fields are Product custom fields. I've copied the code above and below so you can see where it is

	<li id="hikashop_show_tabular_comment_li" class="hikashop_tabs_li ui-corner-top"><?php echo JText::_('PRODUCT_COMMENT');?></li>
			<li id="hikashop_show_tabular_new_comment_li" class="hikashop_tabs_li ui-corner-top"><?php echo JText::_('PRODUCT_NEW_COMMENT');?></li>
			<?php } ?>
		</ul>
		<?php
		if(!empty($this->element->extraData->bottomBegin))
			echo implode("\r\n",$this->element->extraData->bottomBegin);
		?>
      <div class="hikashop_tabs_content" id="listen">
<?php $user = JFactory::getUser();
$groups = isset($user->groups) ? $user->groups : array();
if(in_array(array('7','8','10','11'),$groups)){
		echo $this->element->sm_media;
} else {echo $this->element->sm_preview;}?>	
</div>
		<div class="hikashop_tabs_content" id="hikashop_show_tabular_description">
          
			<div id="hikashop_product_description_main" class="hikashop_product_description_main">
				<?php
				echo JHTML::_('content.prepare',preg_replace('#<hr *id="system-readmore" */>#i','',$this->element->product_description));
				?>
			</div>
			<span id="hikashop_product_url_main" class="hikashop_product_url_main">
				<?php
				if (!empty ($this->element->product_url)) {
					echo JText :: sprintf('MANUFACTURER_URL', '<a href="' . $this->element->product_url . '" target="_blank">' . $this->element->product_url . '</a>');
				}
				?>
			</span>
		</div>

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

  • Posts: 13201
  • Thank you received: 2322
9 years 3 months ago #226151

Hi,

So you will have to do some debug, you can use the "var_dump" PHP function for that.
This can help you so see the groups of your user and so why the if condition is not respected.

var_dump($groups); // to see the groups of the current user
var_dump($this->element->sm_media); // to see the content of this variable
var_dump($this->element->sm_preview);

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

  • Posts: 138
  • Thank you received: 4
9 years 3 months ago #226516

hi xavier,
when add

<?php echo JHTML::_('content.prepare','{loadposition XX}'); ?>
in tab ,other tabs not show andd display error :

Notice: Undefined property: stdClass::$product_description in C:\wamp\www\ponisha\components\com_hikashop\views\product\tmpl\show_tabular.php on line 262


this my show_tabular.php bottom part code :
<div id="hikashop_product_bottom_part" class="hikashop_product_bottom_part show_tabular">
	<div id="hikashop_tabs_div">
		<ul class="hikashop_tabs_ul">
			<li id="hikashop_show_tabular_description_li" class="hikashop_tabs_li ui-corner-top"><a onclick="displayTab('hikashop_show_tabular_description');" href="javascript:void(0);"><?php echo JText::_('PRODUCT_DESCRIPTION');?></a></li>
			<?php if($hide_specs == 0){ ?>
			<li id="hikashop_show_tabular_specification_li" class="hikashop_tabs_li ui-corner-top"><a onclick="displayTab('hikashop_show_tabular_specification');" href="javascript:void(0);"><?php echo JText::_('SPECIFICATIONS');?></a></li>
			<?php }
			if($status_vote == "comment" || $status_vote == "two" || $status_vote == "both" ){
			?>
			<li id="hikashop_show_tabular_comment_li" class="hikashop_tabs_li ui-corner-top"><a onclick="displayTab('hikashop_show_tabular_comment');" href="javascript:void(0);"><?php echo JText::_('PRODUCT_COMMENT');?></a></li>
			<li id="hikashop_show_tabular_new_comment_li" class="hikashop_tabs_li ui-corner-top"><a onclick="displayTab('hikashop_show_tabular_new_comment');" href="javascript:void(0);"><?php echo JText::_('PRODUCT_NEW_COMMENT');?></a></li>
			<?php } ?>
			<li id="hikashop_show_tabular_rahnema_li" class="hikashop_tabs_li ui-corner-top"><a onclick="displayTab('hikashop_show_tabular_rahnema');" href="javascript:void(0);"><?php echo JText::_('PRODUCT_RAHNEMA');?></a></li>
			<li id="hikashop_show_tabular_related_li" class="hikashop_tabs_li ui-corner-top"><a onclick="displayTab('hikashop_show_tabular_related');" href="javascript:void(0);"><?php echo JText::_('PRODUCT_RELATED');?></a></li>


			
		</ul>
		<?php
		if(!empty($this->element->extraData->bottomBegin))
			echo implode("\r\n",$this->element->extraData->bottomBegin);
		?>
		<div class="hikashop_tabs_content" id="hikashop_show_tabular_rahnema">
			<div id="hikashop_product_rahnema_main" class="hikashop_product_rahnema_main">
                <?php 
                 $this->setLayout('show_block_product_files');
	             echo $this->loadTemplate();

                ?>
				
			</div>
			
		</div>
         <div class="hikashop_tabs_content" id="hikashop_show_tabular_related">
			<div id="hikashop_product_related_main" class="hikashop_product_related_main">
                <?php 
                  echo JHTML::_('content.prepare','{loadposition related}'); 
                ?>
				
			</div>
			
		</div>

		
		<div class="hikashop_tabs_content" id="hikashop_show_tabular_description">
			<div id="hikashop_product_description_main" class="hikashop_product_description_main">
				<?php
				echo JHTML::_('content.prepare',preg_replace('#<hr *id="system-readmore" */>#i','',$this->element->product_description));
				?>
			</div>
			<span id="hikashop_product_url_main" class="hikashop_product_url_main">
				<?php
				if (!empty ($this->element->product_url)) {
					echo JText :: sprintf('MANUFACTURER_URL', '<a href="' . $this->element->product_url . '" target="_blank">' . $this->element->product_url . '</a>');
				}
				?>
			</span>
		</div>
		<?php if($hide_specs == 0){ ?>
		<div class="hikashop_tabs_content" id="hikashop_show_tabular_specification">
		<?php
			$this->setLayout('show_block_dimensions');
			echo $this->loadTemplate();
			if(!empty($this->fields)){
				$this->setLayout('show_block_custom_main');
				echo $this->loadTemplate();
			}
		?>
		</div>
		<?php }
if($status_vote == "comment" || $status_vote == "two" || $status_vote == "both" ){ ?>
<form action="<?php echo hikashop_currentURL() ?>" method="post" name="hikashop_comment_form" id="hikashop_comment_form">
		<?php
		if(!empty($this->element->extraData->bottomMiddle))
			echo implode("\r\n",$this->element->extraData->bottomMiddle);
		?>
			<div class="hikashop_tabs_content" id="hikashop_show_tabular_comment">
				<div id="hikashop_product_vote_listing" class="hikashop_product_vote_listing">
					<?php
						echo $layout_vote_listing;
					?>
				</div>
			</div>
			<div class="hikashop_tabs_content" id="hikashop_show_tabular_new_comment">
				<div id="hikashop_product_vote_form" class="hikashop_product_vote_form">
					<?php
						echo $layout_vote_form;
					?>
				</div>
			</div>
</form>
<?php } ?>
<input type="hidden" name="selected_tab" id="selected_tab" value="hikashop_show_tabular_description"/>
		<?php
		if(!empty($this->element->extraData->bottomEnd))
			echo implode("\r\n",$this->element->extraData->bottomEnd);
		?>
	</div>
</div>

other quest...!

how can I simillar description main duplication? means : i want two description main form => 1-description 2-other description
and show both in produst page


Joomla Developer | am.ebrahimzadeh[at]gmail.com
Last edit: 9 years 3 months ago by aminweb.

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

  • Posts: 13201
  • Thank you received: 2322
9 years 3 months ago #226524

Hi,

To have two descriptions for one product, you can create a custom product field.
Then thanks to code like given in previous posts, you can display the desired descriptions where you want on the product page.

www.hikashop.com/support/documentation/4...shop-field-form.html

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

  • Posts: 138
  • Thank you received: 4
9 years 3 months ago #226624

hi Xavier,
First, thank you for your efforts.
how can meta description form change to WYSIWYG editor? (It is essential)
and displaye in produact page tabullar, simiilar description,comment,...
Please explain in detail,very thanks


Joomla Developer | am.ebrahimzadeh[at]gmail.com
Last edit: 9 years 3 months ago by aminweb.

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

  • Posts: 26227
  • Thank you received: 4035
  • MODERATOR
9 years 3 months ago #226636

Hi,

If you have questions which are not related on "add tab on product page" (the title of that thread) ; please create a new thread.

Thanks for your understanding.


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: aminweb

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

  • Posts: 138
  • Thank you received: 4
9 years 3 months ago #227051

related post : www.hikashop.com/forum/product-category-...html?start=40#226035

when add code for show related product in tab,Don`t worked Characterist variant
attach file : show_tabullar.php

File Attachment:

File Name: show_tabular.zip
File Size:4 KB


Joomla Developer | am.ebrahimzadeh[at]gmail.com
Attachments:

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

Time to create page: 0.132 seconds
Powered by Kunena Forum