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


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

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

#1 P.K

P.K

Отправлено 27 January 2014 - 15:22

Hi

Can we submit the metadata from the front end? Also is there any element to do so?

Thanks


  • 0

#2 P.K

P.K

Отправлено 27 January 2014 - 18:58

Also if i need to include the jbprice into the meta description how can i do it?


  • 0

#3 Kess

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.


Сообщение отредактировал Kess: 28 January 2014 - 00:27

  • 0

#4 P.K

P.K

Отправлено 28 January 2014 - 10:49

Hello

it works

but the issue i need to use the price inside text so how can i do that? Can i make it fixed in the full.php so that it gets the name and price directly.

Or is there any other alternative method using elements in your mind?

 

Thanks


  • 0

#5 Kess

Kess

Отправлено 28 January 2014 - 12:40

I'm not sure I understand your problem with price. Did you try to add it to that position along with other elements? Does something works wrong? That screenshot was just an example, you can assign elements as you wish.


Сообщение отредактировал Kess: 28 January 2014 - 12:41

  • 0

#6 P.K

P.K

Отправлено 28 January 2014 - 14:57

Hi

Everything works fine as you its just that i need it a litle different. I need to have the meta description as a sentence like Sample product is available for 34000 

So i cant make this by using the elements in the full layout. For it i would have to edit the full.php so as to access the get->name and the price as it is available there only.

What could be the solution?


  • 0

#7 Kess

Kess

Отправлено 29 January 2014 - 00:01

You don't need to use get->name or other similar things in full.php. That's why we added a rendering of new positions there. All that you will assign to that position in your item type settings will get to the metadata.

So in your example you can do the following:

Create a new text element with the default value which is a part of that sentence - " is available for ".

s74_200x0.png

 

Then open the settings of your "Full" layout and put "Name", sentence part and "Price" elements to the "Meta description" position like this:

0z4_200x0.png

 

Name element is from the core fields.

 

These elements will be rendered in the full.php within this function that I provided before:

$document->setMetadata('description', strip_tags(trim($this->renderPosition('meta-description'))));

So this should be what you need.


  • 0

#8 P.K

P.K

Отправлено 29 January 2014 - 06:11

hi

I was planning to make a complex sentence like the price of sample product is '' and is available with free shipping.

So this means i would have to combine a lot of elements to make it. And i am afraid that it doesnt include unnecessarily sql queries.

That is the reason i was asking if we could do it in the template files itself


  • 0

#9 P.K

P.K

Отправлено 05 February 2014 - 19:28

hi 

I wish to have the image url of jbzoo image in full.php . If i use strip-tags then img tags are removed but i cant get the url from the src attribute. I dont want to use preg_replace. Do we have any variable for the url of image in the full.php?


  • 0

#10 SmetDenis

SmetDenis

Отправлено 05 February 2014 - 19:58

Hi

 

Try this

 

<?php
$imageData = (array)$item->getElement('<ELEMENT_ID>')->data();
print_r($imageData); // $imageData['file'] or $imageData[0]['file']

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



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





Click to return to top of page in style!