Перейти к содержимому


Фотография
- - - - -

Item URL

url

Лучший Ответ SmetDenis , 03 March 2014 - 18:49

Hi

 

If you use item template e.g. modules\mod_zooitem\renderer\item\*.php

You don't need in  line

$item = $app->table->item->get('42'); // IT'S ONLY FOR EXAMPLE

because var $item already defined there

 

As result, you will have

$itemUrl = $app->route->item($item);
?>
<a class="urllink" href="<?php echo $itemUrl; ?>">
    // some HTML code
</a>

I check, this works fine.

Перейти к сообщению


  • Закрытая тема Тема закрыта
Сообщений в теме: 15

#11 P.K

P.K

Отправлено 02 March 2014 - 06:06

Hi

Can you let me know the file in which i should use it? As while using in 

/public_html/modules/mod_zooitem/tmpl/list.php

i get 

Fatal error: Using $this when not in object context in /public_html/modules/mod_zooitem/tmpl/list.php on line 17

 

and while using in modules/mod_zooitem/renderer/item/default.php

The url remains the same and doesnt changes

 

thanks


  • 0

#12 SmetDenis

SmetDenis

Отправлено 02 March 2014 - 07:20

Hi

 

Sorry, but I can't understand you.

 

Zoo Item module can output item links via templates (elements and positions).

Do you use them?

Why url must be changed?

Please, explain me your issue in details.

 

Thanks.

 

 

Alternative code

$app = App::getInstance('zoo');
 
$item = $app->table->item->get('42'); // if we don't have $item variable than get it by ID=42

$itemUrl = $app->route->item($item);
echo '<a href='.$itemUrl.'>Item url</a>';

  • 0
JBZoo v4.0 и новый чудный мир Open Source GPL
Отключайте проверку лицензий как можно скорее!



— Есть два типа людей: Кто еще не делает бекапы и кто уже делает бекапы.


#13 P.K

P.K

Отправлено 02 March 2014 - 07:57

Hi

What i am trying to do is that i am creating an container for zoo item so that the entire area is clickable(using the anchor tag). So i am unable to use the item url element 

But the code you gave is still giving error in 

/public_html/modules/mod_zooitem/tmpl/list.php

Using $this when not in object context 

I hope you understand

thanks


  • 0

#14 SmetDenis

SmetDenis

Отправлено 03 March 2014 - 09:29

Hi

 

My code form second way doesn't have $this variable.

 

Maybe the best way for item url will be - item template ?

modules\mod_zooitem\renderer\item\*.php

 

Because, modules/mod_zooitem/tmpl/list.php is template for wrapping list of items.

 

Can show me all code from your temmplate?

 

Thanks.


  • 0
JBZoo v4.0 и новый чудный мир Open Source GPL
Отключайте проверку лицензий как можно скорее!



— Есть два типа людей: Кто еще не делает бекапы и кто уже делает бекапы.


#15 P.K

P.K

Отправлено 03 March 2014 - 13:14

Hi

I tried it out but the url is coming out to be the same even when product changes. The code is

<?php
/**
* @package   ZOO Item
* @author    YOOtheme http://www.yootheme.com
* @copyright Copyright (C) YOOtheme GmbH
* @license   http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
*/

// no direct access
defined('_JEXEC') or die('Restricted access');

$media_position = $params->get('media_position', 'top');
$app = App::getInstance('zoo');
 
$item = $app->table->item->get('42'); // if we don't have $item variable than get it by ID=42
 
$itemUrl = $app->route->item($item);
?>
<a class="urllink" href="<?php echo $itemUrl; ?>">

<div class="layout-default <?php if ($media_position == 'top' || $media_position == 'middle' || $media_position == 'bottom') echo 'alignment-center'; ?>">

	<?php if (($media_position == 'top' || $media_position == 'left' || $media_position == 'right') && $this->checkPosition('media')) : ?>
	<div class="media media-<?php echo $media_position; ?>"><?php echo $this->renderPosition('media'); ?></div>
	<?php endif; ?>
	
	<?php if ($this->checkPosition('title')) : ?>
	<h3 class="title"><?php echo $this->renderPosition('title'); ?></h3>
	<?php endif; ?>
	
	<div class="l1">
	<?php if ($this->checkPosition('tab')) : ?>
	<div class="tab"><?php echo $this->renderPosition('tab', array('style' => 'block')); ?></div>
	<?php endif; ?>
	<?php if ($this->checkPosition('price')) : ?>
	<div class="price"><?php echo $this->renderPosition('price', array('style' => 'block')); ?></div>
	<?php endif; ?>
	</div>
	<?php if ($this->checkPosition('meta')) : ?>
	<p class="meta"><?php echo $this->renderPosition('meta', array('style' => 'comma')); ?></p>
	<?php endif; ?>
	
	<?php if (($media_position == 'middle') && $this->checkPosition('media')) : ?>
	<div class="media media-<?php echo $media_position; ?>"><?php echo $this->renderPosition('media'); ?></div>
	<?php endif; ?>
	
	<?php if (($media_position == 'bottom') && $this->checkPosition('media')) : ?>
	<div class="media media-<?php echo $media_position; ?>"><?php echo $this->renderPosition('media'); ?></div>
	<?php endif; ?>
	<div class="ceta">
	<?php if ($this->checkPosition('ab4c')) : ?>
	<div class="deta"><?php echo $this->renderPosition('ab4c', array('style' => 'block')); ?></div>
	<?php endif; ?>
	<?php if ($this->checkPosition('links')) : ?>
	<p class="links"><?php echo $this->renderPosition('links', array('style' => 'pipe')); ?></p>
	<?php endif; ?>
	</div>

	

</div>
</a>

  • 0

#16 SmetDenis

SmetDenis

Отправлено 03 March 2014 - 18:49   Лучший Ответ

Hi

 

If you use item template e.g. modules\mod_zooitem\renderer\item\*.php

You don't need in  line

$item = $app->table->item->get('42'); // IT'S ONLY FOR EXAMPLE

because var $item already defined there

 

As result, you will have

$itemUrl = $app->route->item($item);
?>
<a class="urllink" href="<?php echo $itemUrl; ?>">
    // some HTML code
</a>

I check, this works fine.


  • 0
JBZoo v4.0 и новый чудный мир Open Source GPL
Отключайте проверку лицензий как можно скорее!



— Есть два типа людей: Кто еще не делает бекапы и кто уже делает бекапы.






Темы с аналогичным тегами url

Click to return to top of page in style!