Гость
29 Янв 2014 11:44

I don't know if this is possible and how much complicated to do,

but I'd like to do this for SEO purposes:

for a certain type automatically add a string of text to all the title aliases generated for its records

eg

alias-wathever-is-generated-customword

or

customword-alias-wathever-is-generated

thank you

Последние изменения: 02 Март 2014


Sergey
Total posts: 13,748
31 Янв 2014 07:06

you will have to copy router_main.php file in routers folder, modify it and set it as your main router.


Гость
31 Янв 2014 07:26

thank you,

but will I be able to set a custom alias only for certain types, and not for all?


Sergey
Total posts: 13,748
02 Фев 2014 23:53

but will I be able to set a custom alias only for certain types, and not for all?

Yes. There you can check ID and if it is what you need to change alias.


Sergey
Total posts: 13,748
04 Фев 2014 00:43

Router is pure PHP.

Documentation


Гость
06 Фев 2014 09:45

Yes. There you can check ID and if it is what you need to change alias. Yes. There you can check ID and if it is what you need to change alias.

I have no idea how to that :(, if anyone can suggest the code to do it I will appreciate it.

thank you


Sergey
Total posts: 13,748
07 Фев 2014 00:06

Find lines 279-280 in current router

$record = explodeUrlParam($query['id']);

$segments[] = $record[0] . (isset($record[1]) ? '-' . cleanAlias($record[1]) : '');

change it to

$record = explodeUrlParam($query['id']);

$alias = (isset($record[1]) ? $record[1] : '');

$record_obj = ItemsStore::getRecord($record[0]);

if(in_array($record_obj->type_id, array(2,3,4)))

{

$alias .= (!empty($alias) ? '-customword' : 'customword' );

}

$segments[] = $record[0] . (!empty($alias) ? '-' . cleanAlias($alias) : '');

This is not tested and typed right here. So may be some errors but this is main idea.

Also copy router first first and the set it in global cobalt config.

Работает на Cobalt