We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

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.9k
edited Jul '15

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



8.6k
edited Jul '15

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

Not Work :(



6.9k
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.

https://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.



8.6k

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.