News:

Support the VirtueMart project and become a member

Main Menu

Create a Meta based on URL

Started by Meton, January 20, 2016, 16:54:15 PM

Previous topic - Next topic

Meton

Hi guys,

Maybe this question is more for a joomla forum but ill give it a go here.

I am experiencing a couple of issues with the meta and title tags in virtuemart. As a example when you create a manufacturer and link to a catagory with the manufacturer there is no way to set a meta desc and title.

Example, when you create a link to:

URL/product/manufacturer/name/catagory

-----------------------------------------

What i would like to do is create a small script in php that looks at a URL and replaces the meta data and title. example

if url = /product/manufacturer/brandA/catagory{

set meta description to xxxxx
}

Does anyone know how this is done or a good extention to do this?

Kind regards,

Meton
Joomla!         3.6.5
VirtueMart     3.0.18

Studio 42

You can get meta tag, if manufacturer ID is set and add the manufacturer name, after or before and resend back to Joomla the meta

this is the base code:
$mid = vRequest::getInt('virtuemart_manufacturer_id');
if($mid) {
$doc = JFactory::getDocument();
$metaDesc= $doc->getDescription();
$doc->setDescription($metaDesc.' '.$this->product->mf_name) ;
}

Meton

Quote from: Studio 42 on January 20, 2016, 18:48:57 PM
You can get meta tag, if manufacturer ID is set and add the manufacturer name, after or before and resend back to Joomla the meta

this is the base code:
$mid = vRequest::getInt('virtuemart_manufacturer_id');
if($mid) {
$doc = JFactory::getDocument();
$metaDesc= $doc->getDescription();
$doc->setDescription($metaDesc.' '.$this->product->mf_name) ;
}


Hi m8, thank you for your reply.

The problem is i cannot set the meta data for subs of a manufacturer. (brand\catagory).
Joomla!         3.6.5
VirtueMart     3.0.18

Meton

#3
Hi All,

Just to check, I have written a simple code that seems to do the job. Did i do this correctly, am i in any risk of breaking default functions?

The code:



$oudeTitle = $this->getTitle();
$oudeDesc = $this->getDescription();

if (preg_match("/merk.*?bruder.?$/" , $this->base)){
$title = 'Bruder';
$metadesc ='Meta brand desc';
}

elseif (preg_match("/merk.*?bruder.*?aanhangers.?$/" , $this->base)){
$title = 'aanhanger meta title';
$metadesc ='brand subs meta.';

}

elseif (preg_match("/merk.*?bruder.*?accessoires.?$/" , $this->base)){
$title = 'accessoires';
$metadesc ='Meta desc accessoires';

}

else{

echo '<b>GEEN DATAWIJZIGING!</b> <br><br>';
};



$this->setTitle($title);
$this->setDescription($metadesc);
$this->setMetaData('title',$title);

echo '<b>OUDE GEGEVENS:</b> <br>';
echo '<b>Meta title:</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '.$oudeTitle . '<br>' ;
echo '<b>Meta desc:</b>&nbsp;&nbsp;&nbsp;&nbsp; '.$oudeDesc. '<br><br>' ;

echo '<b>NIEUWE GEGEVENS:</b> <br>';
echo '<b>Meta title:</b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$this->getTitle(). '<br>' ;
echo '<b>Meta desc:</b> &nbsp;&nbsp;&nbsp;&nbsp;'.$this->getDescription(). '<br><br>' ;

?>


I did not take the time to write a function so please forgive me :P

Kind regards,

Meton
Joomla!         3.6.5
VirtueMart     3.0.18

Studio 42

Meta description, need to be encoded corrretly and no HTML !!! only simple text