Skip to main content
Topic: Using a field value in page title and page header. (Read 1939 times) previous topic - next topic

Using a field value in page title and page header.

How can I use a value from a field in the page title?

For example: table 'Clients' has fields 'id', 'company' and 'country'
One record is: 12, Microsoft, USA

When I view this clients record I want the page title to be:
"Clients View - Microsoft, USA"
Same goes for the Header component on the Page Design of Clients View.

What I've done is this:
I added to Page Events-BeforeView
Code: [Select]
clear_session("company_name");
//query the database and return a single field value
$db->where("id", $rec_id);
set_session("company_name", $db->getValue("clients", "company"));
and then use get_session("company_name") in the Header component but doesnt work, it shows: get_session("company_name")
and then I used <?php echo get_session("company_name"); ?>  in the Header component -- but doesnt work either it just puts <?php echo get_session("company_name"); ?> in HTML.

How can I get show the company name???

Re: Using a field value in page title and page header.

Reply #1
@willvin would you happen to know how?

Re: Using a field value in page title and page header.

Reply #2
@Erwin‍ Please you have to edit the page manually using file explorer to apply your code and for it to work, thanks.

 

Re: Using a field value in page title and page header.

Reply #3
As a suggestion for the next version of PHPRad, I would welcome some kind of indicator (or documentation) what each field, property, setting and component accept as input. These being, plain text, HTML, PHP script with or without the <?php tag, JavaScript or SQL query.
Now for some of these it’s stated in the description box but others aren’t as clear or obvious.
Cheers!