Foren

Changing the web page's title

ntumba lobo, geändert vor 15 Jahren.

Changing the web page's title

New Member Beiträge: 10 Beitrittsdatum: 13.10.08 Neueste Beiträge
Hi,
I would like to know if there is a way from a portal page to change the web page's title.
Let's say we have a portlet that can display different types of content. The idea would be to change the web page's title
according to the type of content currently displayed (more convenient for bookmarking).

I would like to avoid updating the <title> element via javascript, does liferay give access to this element via an API ?

thanks in advance.
thumbnail
Thiago Moreira, geändert vor 15 Jahren.

RE: Changing the web page's title

Liferay Legend Beiträge: 1449 Beitrittsdatum: 10.10.07 Neueste Beiträge
Hey Ntumba

You can use this:

com.liferay.portal.util.PortalUtil.setPageTitle(String, title, HttpServletRequest request);


you can also use the setPageSubtitle of the same class.

Choose the best one for you!

Um abraço
ntumba lobo, geändert vor 15 Jahren.

RE: Changing the web page's title

New Member Beiträge: 10 Beitrittsdatum: 13.10.08 Neueste Beiträge
Thanks Thiago that was exactly what I need and it works !
Yan Naing Oo, geändert vor 12 Jahren.

RE: Changing the web page's title

Regular Member Beiträge: 179 Beitrittsdatum: 17.02.11 Neueste Beiträge
Thiago Leão Moreira:
Hey Ntumba

You can use this:

com.liferay.portal.util.PortalUtil.setPageTitle(String, title, HttpServletRequest request);


you can also use the setPageSubtitle of the same class.

Choose the best one for you!

Um abraço




Hi Thiago,

If i want to put the in directory under userdetails.jsp ? is that change ? what i need is the page title with dynamic user name on page title.

thanks
yang
thumbnail
Ravi Kumar Gupta, geändert vor 12 Jahren.

RE: Changing the web page's title

Liferay Legend Beiträge: 1302 Beitrittsdatum: 24.06.09 Neueste Beiträge
an event hook should help in this case.. give it a try.. emoticon
Yan Naing Oo, geändert vor 12 Jahren.

RE: Changing the web page's title

Regular Member Beiträge: 179 Beitrittsdatum: 17.02.11 Neueste Beiträge
HI everyone,

here I use directory portlet, I want to show the each user name on the page title once i click on the selected user.
where do i override the page title for dynamic user directory ?
attached img as below.
can anybody know ? thanks
thumbnail
Ravi Kumar Gupta, geändert vor 12 Jahren.

RE: Changing the web page's title

Liferay Legend Beiträge: 1302 Beitrittsdatum: 24.06.09 Neueste Beiträge
A simple approach can be using javascript
document.title = "title-goes-here";


Create a simple jsp hook for the directory portlet. Modify the init.jsp or the respective jsp to get user's name and put into <script> tag..
HTH
Yan Naing Oo, geändert vor 12 Jahren.

RE: Changing the web page's title

Regular Member Beiträge: 179 Beitrittsdatum: 17.02.11 Neueste Beiträge
Ravi Kumar Gupta:
A simple approach can be using javascript
document.title = "title-goes-here";


Create a simple jsp hook for the directory portlet. Modify the init.jsp or the respective jsp to get user's name and put into <script> tag..
HTH


Hi Kumar,

According to your suggestion that I am working fine with that idea and below is working code snippets.

<SCRIPT LANGUAGE = "JavaScript">
var name="<%= HtmlUtil.escape(selUser.getFullName()) %>";
document.title = "Directory Browse - "+name;
</SCRIPT>


thanks
yang