Php Code for different language on product descrip

  • Posts: 177
  • Thank you received: 1
9 years 4 months ago #237749

-- HikaShop version -- : free
-- Joomla version -- : latest
-- PHP version -- : latest

Hi All,
i'm trying tu use TAB into php code using different language.

I can't understand my error!
Can u help me?


Please check the attachment!

Attachments:
Last edit: 9 years 4 months ago by andreasuriani.

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

  • Posts: 13201
  • Thank you received: 2322
9 years 4 months ago #237781

Hi,

I bet that nothing is displayed ;) You should use that code instead:

<?php

// Override the products description depending the current language
//

$desc_en = 'ciao';

$desc_it = ' <p>


</p> ' ;


$lang = JFactory::getLanguage();
switch($lang->getTag()){
 default:
 case 'en-GB':
  echo $desc_en ; 
  break;
 case 'it-IT':
  echo $desc_it ;
  break;

}
?>

The PHP "echo" can't be passed in the text string else it will not be interpreted.

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

  • Posts: 177
  • Thank you received: 1
9 years 4 months ago #237808

Hi Xavier,
unfortunately it seems doesn't works!
Page is loading but nothing is shows!

In attachment the php file.

Can u check it?

:( Sorry about it.

A.

Attachments:

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

  • Posts: 13201
  • Thank you received: 2322
9 years 4 months ago #237814

Hi,

The code was not the one I gave you:

<?php
/**
 * @package	HikaShop for Joomla!
 * @version	2.6.2
 * @author	hikashop.com
 * @copyright	(C) 2010-2016 HIKARI SOFTWARE. All rights reserved.
 * @license	GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
 */
defined('_JEXEC') or die('Restricted access');
?><div id="hikashop_product_top_part" class="hikashop_product_top_part">
	<?php if(!empty($this->element->extraData->topBegin)) { echo implode("\r\n",$this->element->extraData->topBegin); } ?>
	<h1>
		<span id="hikashop_product_name_main" class="hikashop_product_name_main" itemprop="name">
			<?php
			if (hikashop_getCID('product_id')!=$this->element->product_id && isset ($this->element->main->product_name))
				echo $this->element->main->product_name;
			else
				echo $this->element->product_name;
			?>
		</span>
		<?php if ($this->config->get('show_code')) { ?>
		<span id="hikashop_product_code_main" class="hikashop_product_code_main" itemprop="sku">
			<?php
			echo $this->element->product_code;
			?>
		</span>
		<?php } ?>
	</h1>
	<?php if(!empty($this->element->extraData->topEnd)) { echo implode("\r\n",$this->element->extraData->topEnd); } ?>
	<?php
		$this->setLayout('show_block_social');
		echo $this->loadTemplate();
	?>
</div>
<?php if(HIKASHOP_RESPONSIVE){ ?>
<div class="<?php echo HK_GRID_ROW; ?>">
<?php } ?>
	<div id="hikashop_product_left_part" class="hikashop_product_left_part <?php echo HK_GRID_COL_6; ?>">
		<?php
		if(!empty($this->element->extraData->leftBegin)) { echo implode("\r\n",$this->element->extraData->leftBegin); }

		$this->row = & $this->element;
		$this->setLayout('show_block_img');
		echo $this->loadTemplate();

		if(!empty($this->element->extraData->leftEnd)) { echo implode("\r\n",$this->element->extraData->leftEnd); }
		?>
	</div>

	<div id="hikashop_product_right_part" class="hikashop_product_right_part <?php echo HK_GRID_COL_6; ?>">
		<?php
		if(!empty($this->element->extraData->rightBegin))
			echo implode("\r\n",$this->element->extraData->rightBegin);
		?>
      <h4>
        Tags
      </h4>
      <?php
		if(!empty($this->fields)){
			$this->setLayout('show_block_custom_main');
			echo $this->loadTemplate();
		}

		if(HIKASHOP_J30) {
			$this->setLayout('show_block_tags');
			echo $this->loadTemplate();
		}

		?>
		<div id="hikashop_product_vote_mini" class="hikashop_product_vote_mini">
			<h4>
              Voti
          </h4><?php
			$config =& hikashop_config();
			if($this->params->get('show_vote_product') == '-1'){
				$this->params->set('show_vote_product',$config->get('show_vote_product'));
			}
			if($this->params->get('show_vote_product')){
				$js = '';
				$this->params->set('vote_type','product');
				if(isset($this->element->main)){
					$product_id = $this->element->main->product_id;
				}else{
					$product_id = $this->element->product_id;
				}
				$this->params->set('vote_ref_id',$product_id);
				echo hikashop_getLayout('vote', 'mini', $this->params, $js);
			}
			?>
		</div>
		<span id="hikashop_product_price_main" class="hikashop_product_price_main"  itemprop="offers" itemscope itemtype="http://schema.org/Offer">
		<h4>
          Prezzo
          </h4>	
          <?php
			if ($this->params->get('show_price')) {
				$this->row = & $this->element;
				$this->setLayout('listing_price');
				echo $this->loadTemplate();

				$CurrId = hikashop_getCurrency();
				$null = null;
				$currency = $this->currencyHelper->getCurrencies($CurrId, $null);
				$CurrCode = $currency[$CurrId]->currency_code;

			?>
				<span style="display: none;" itemprop="priceCurrency"><?php echo $CurrCode; ?></span>
			<?php
			}
			?>
		</span>
			<?php
		if(!empty($this->element->extraData->rightMiddle))
			echo implode("\r\n",$this->element->extraData->rightMiddle);
		?>
		<?php
			$this->setLayout('show_block_dimensions');
			echo $this->loadTemplate();
		?><br />
		<?php
		if($this->params->get('characteristic_display') != 'list') {
			$this->setLayout('show_block_characteristic');
			echo $this->loadTemplate();
			?>
			<br />
		<?php
		}

		$form = ',0';
		if (!$this->config->get('ajax_add_to_cart', 1)) {
			$form = ',\'hikashop_product_form\'';
		}
		if (hikashop_level(1) && !empty ($this->element->options)) {
		?>
			<div id="hikashop_product_options" class="hikashop_product_options">
				<?php
				$this->setLayout('option');
				echo $this->loadTemplate();
				?>
			</div>
			<br />
			<?php
			$form = ',\'hikashop_product_form\'';
			if ($this->config->get('redirect_url_after_add_cart', 'stay_if_cart') == 'ask_user') {
			?>
				<input type="hidden" name="popup" value="1"/>
			<?php
			}
		}
		if (!$this->params->get('catalogue') && ($this->config->get('display_add_to_cart_for_free_products') || ($this->config->get('display_add_to_wishlist_for_free_products', 1) && hikashop_level(1) && $this->params->get('add_to_wishlist') && $config->get('enable_wishlist', 1)) || !empty($this->element->prices))) {
			if (!empty ($this->itemFields)) {
				$form = ',\'hikashop_product_form\'';
				if ($this->config->get('redirect_url_after_add_cart', 'stay_if_cart') == 'ask_user') {
				?>
					<input type="hidden" name="popup" value="1"/>
				<?php
				}
				$this->setLayout('show_block_custom_item');
				echo $this->loadTemplate();
			}
		}
		$this->formName = $form;
		if($this->params->get('show_price')){ ?>
			<span id="hikashop_product_price_with_options_main" class="hikashop_product_price_with_options_main">
			</span>
		<?php }
		if(empty ($this->element->characteristics) || $this->params->get('characteristic_display')!='list'){ ?>
		<?php } ?>
		<div id="hikashop_product_contact_main" class="hikashop_product_contact_main">
			<?php
			$contact = $this->config->get('product_contact',0);
			if (hikashop_level(1) && ($contact == 2 || ($contact == 1 && !empty ($this->element->product_contact)))) {
				$empty = '';
				$params = new HikaParameter($empty);
				global $Itemid;
				$url_itemid='';
				if(!empty($Itemid)){
					$url_itemid='&Itemid='.$Itemid;
				}
				echo $this->cart->displayButton(JText :: _('CONTACT_US_FOR_INFO'), 'contact_us', $params, hikashop_completeLink('product&task=contact&cid=' . $this->element->product_id.$url_itemid), 'window.location=\'' . hikashop_completeLink('product&task=contact&cid=' . $this->element->product_id.$url_itemid) . '\';return false;');
			}
			?>
		</div>
		
		<span id="hikashop_product_id_main" class="hikashop_product_id_main">
			<input type="hidden" name="product_id" value="<?php echo $this->element->product_id; ?>" />
		</span>
		<?php
		if(!empty($this->element->extraData->rightEnd))
			echo implode("\r\n",$this->element->extraData->rightEnd);
		?>
	</div>
	<?php if(HIKASHOP_RESPONSIVE){ ?>
</div>
<?php } ?>
<div id="hikashop_product_bottom_part" class="hikashop_product_bottom_part">
	<?php
	if(!empty($this->element->extraData->bottomBegin))
		echo implode("\r\n",$this->element->extraData->bottomBegin);
	?>
	<div id="hikashop_product_description_main" class="hikashop_product_description_main" itemprop="description">
      
        <?php

        // Override the all products description depending the current language
        //

     $desc_en = 'ciao';
     $desc_it = '<p>
        


</p>
        </p> ' ;


    $lang = JFactory::getLanguage();
	switch($lang->getTag()){
		default:
		case 'en-GB':
			echo $desc_en; 
			break;
		case 'it-IT':
			echo $desc_it;
			break;
	}   
        ?>
	</div>
  <div id="hikashop_product_quantity_main" class="hikashop_product_quantity_main">
				<?php
				$this->row = & $this->element;
				$this->ajax = 'if(hikashopCheckChangeForm(\'item\',\'hikashop_product_form\')){ return hikashopModifyQuantity(\'' . $this->row->product_id . '\',field,1' . $form . ',\'cart\'); } else { return false; }';
				$this->setLayout('quantity');
				echo $this->loadTemplate();
				?>
			</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>
	<?php
	$this->setLayout('show_block_product_files');
	echo $this->loadTemplate();
	?>
	<?php
	if(!empty($this->element->extraData->bottomMiddle))
		echo implode("\r\n",$this->element->extraData->bottomMiddle);
	?>
	<?php
	if(!empty($this->element->extraData->bottomEnd))
		echo implode("\r\n",$this->element->extraData->bottomEnd);
	?>
</div>

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

  • Posts: 177
  • Thank you received: 1
9 years 4 months ago #237897

I don't know why but I'm not able to see correct this code. Can you kindly save it in a external file?
(I see the real tab on the code :( )

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

  • Posts: 84311
  • Thank you received: 13701
  • MODERATOR
9 years 4 months ago #237909

Here you go:

File Attachment:

File Name: file.txt
File Size:9 KB

Attachments:

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

  • Posts: 177
  • Thank you received: 1
9 years 4 months ago #237930

Merci NIcolas!!

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

  • Posts: 177
  • Thank you received: 1
9 years 4 months ago #239377

Hi Guys,
sorry to disturb you again but i'm trying to put in the tabs the option products.. and i have a phrase error on php but i can't realize my issue.

The code is:

 <?php

        // Override the all products description depending the current language
        //

     $desc_en = 'ciao';
     $desc_it = '<p>
        


</p>
        </p> ' ;


    $lang = JFactory::getLanguage();
	switch($lang->getTag()){
		default:
		case 'en-GB':
			echo $desc_en; 
			break;
		case 'it-IT':
			echo $desc_it;
			break;
	}   
        ?>
Where is my issue??

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

  • Posts: 84311
  • Thank you received: 13701
  • MODERATOR
9 years 4 months ago #239382

Hi,

The line:
$desc_it = '<p>
is wrong.
It should be:
$desc_it = '<p>';

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

  • Posts: 177
  • Thank you received: 1
9 years 4 months ago #239562

Hi Nicolas,
i did it but it doesn't works.

In attachment the code.

Attachments:
Last edit: 9 years 4 months ago by andreasuriani.

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

  • Posts: 13201
  • Thank you received: 2322
9 years 4 months ago #239569

Hi,

You have to use that code instead:

$desc_it = '<p>
        


</p>' ;
In you code there was:
$this->setLayout('option');$this->setLayout('option')
So it can't be valid, you only need: $this->setLayout('option')

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

  • Posts: 177
  • Thank you received: 1
9 years 4 months ago #239641

Hi Xavier,
unfortunately it doesn't work. I see only the write "option" in the table and not Hikashop option .. :(

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

  • Posts: 13201
  • Thank you received: 2322
9 years 4 months ago #239651

Hi,

Please give us a backend access to your website via our contact form with a link to this topic in your message.
www.hikashop.com/support/contact-us.html

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

  • Posts: 84311
  • Thank you received: 13701
  • MODERATOR
9 years 4 months ago #239912

Hi,

The code $this->setLayout('option') will set the layout name for the next time the loadTemplate function is called.
It's not meant to display anything so it's normal that you get that result.
If you want to display the layout option there, you need to do like that:
$this->setLayout('option');
echo $this->loadTemplate();
Exactly like it's done in the "ciao ciao" area of your layout.

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

  • Posts: 177
  • Thank you received: 1
9 years 4 months ago #239917

Hi,
yes, i did it in the last update but it doesn't show. As you asked me, i've sent you the admin access to check it.

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

  • Posts: 84311
  • Thank you received: 13701
  • MODERATOR
9 years 4 months ago #239924

Hi,

No, I don't see that in your website: take.ms/Mwq1A
You're still using just $this->setLayout('option') instead of what I said.
So please follow our instructions and it will work.
Please understand that such customization is outside the user support we offer. We already helped quite a lot here. If you can't do it yourself, please contact a third party developer for help:
www.hikashop.com/home/our-partners.html

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

Time to create page: 0.092 seconds
Powered by Kunena Forum