Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

How to set custom title in Phalcon Controller

I was created a main layout , layouts , and controller view .

But how to set custom title product / name in view ?

Main layouts

{{ get_doctype() }}

<html>
<head>
{{ get_title() }}

</head>
<body>
{{ content() }}

</body>

</html>

Layouts

{{ content() }}

And Controllers View

"Controller View"

In IndexController

Phalcon\Tag::setTitle("Welcome to my Page");

And Nothing return ? Please help !



6.0k
edited Jul '15

try using: $this->tag->setTitle("Welcome to my Page"); instead of the static setTitle you're using.



3.0k
edited Jul '15

try using: $this->tag->setTitle("Welcome to my Page"); instead of the static setTitle you're using.

Not Work :(



6.0k
Accepted
answer

How exactly is not working? Title is only to define a title in the browser toolbar. It won't show on your view page.

http://www.w3schools.com/tags/tag_title.asp

If you want to print the title on the view page put {{ get_title(false) }}. This will disable the title tags and will be visible. But in that case I suggest you to set a different variable in controller to handle only the view title. The page title can be appended or prepended and later you might want to add the website name on it and you won't want to be shown on view.



3.0k

It work now ! Tks to #Rian Orie,Stefan :)

Please accept the correct answer so others that have a similar problem in the future can see what the solution is.