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


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

meta


Лучший Ответ Kess , 28 January 2014 - 00:25

Hello,
 
There are no elements for this but you can make it using special positions.
 
For example, we need to add keywords and description, then add this to the full.php of your item type, right next after this line:

defined('_JEXEC') or die('Restricted access');

add

$document = JFactory::getDocument();
$document->setMetadata('description', strip_tags(trim($this->renderPosition('meta-description'))));
$document->setMetadata('keywords', strip_tags(trim($this->renderPosition('meta-keywords'))));

This will use standard Joomla function to set metadata. And we output the data from our new positions there. 
 
We also need to add these new positions to the full layout in positions.xml:

<position name="meta-description">Meta description</position> 
<position name="meta-keywords">Meta keywords</position>

Now you can go to the configuration of your full layout and add some existing fields to these positions if you want them to be filled automatically with existing elements. Or if you need to add more keywords, you can make a new text element for this and put it in the submission as well.
 
7c3_200x0.png
 
 
If you want keywords to be separated by comma when using existing elements, you can change it's style like this:

$document->setMetadata('keywords', strip_tags(trim($this->renderPosition('meta-keywords', array('style' => 'comma')))));

For the price it's better to use its simplest template.

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


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

#11 P.K

P.K

Отправлено 06 February 2014 - 07:20

Hi

Solves it.

Last thing is that this is giving relative path. /images/abc.png

How to i make it www.site.com/images/abc.png

 

Also I small problem for Kess. The trim function is not removing the white space and in the source it is like

gs83.jpg

I dont know why is this happening after using trim function. May be this is due to space after elements


  • 0

#12 SmetDenis

SmetDenis

Отправлено 07 February 2014 - 12:40

Hi,

 

How to i make it www.site.com/images/abc.png

 

Try this

<?php
$url = JUri::root() .'images/img.png';
 

And secondly,

$desc = $this->renderPosition('meta-description');
$desc = strip_tags(trim($desc));
$desc = str_replace(array("\n", "\r"), ' ', $desc); // remove white spaces and line breaks
$document->setMetadata('description', $desc);

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



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





Click to return to top of page in style!