Foros de discusión

Changing page title in velocity template

Thibault Griez, modificado hace 14 años.

Changing page title in velocity template

New Member Mensajes: 4 Fecha de incorporación: 4/02/10 Mensajes recientes
Hello,

I hope someone can help me with this one...

I need to change the page title from within a velocity template (Journal content template).
I know we can use the PortalUtil.setPageTitle method to do that, I've successfully done it from a portlet action but I cannot get this to work from a velocity template.
I know we are supposed to have access to the portalutil from velocity but I don't have access to a "real" http request ($request being only a hashmap) so how can I change the page title...

Could someone help me ?

Thanks a lot.
Ramy Georgy, modificado hace 13 años.

RE: Changing page title in velocity template

New Member Mensajes: 10 Fecha de incorporación: 18/08/09 Mensajes recientes
Hi Thibault,

I wanted to do exactly the same and also didn't find any way to do it through the API. So I ended up using simple javascript to accomplish that.

I put the following code at the bottom of the journal template:

<script type="text/javascript">
document.title = 'My Test Title';
</script>

That seems to work. I hope it will help you.
Yan Naing Oo, modificado hace 12 años.

RE: Changing page title in velocity template

Regular Member Mensajes: 179 Fecha de incorporación: 17/02/11 Mensajes recientes
Ramy Georgy:
Hi Thibault,

I wanted to do exactly the same and also didn't find any way to do it through the API. So I ended up using simple javascript to accomplish that.

I put the following code at the bottom of the journal template:

<script type="text/javascript">
document.title = 'My Test Title';
</script>

That seems to work. I hope it will help you.



Hi Ramy,

the code you mentioned is work but how can i get the IE view source to get <title> ... </title> tags change? need to get for seo.
it will search engines index pages with dynamically swapped titles?
anybody know ?
thanks