Page 1 of 1
How to add meta from database to view pages?
Posted: Sat Sep 07, 2024 12:25 am
by mehmetbkm
I need to add a value from the database to every view page. I wrote the code below, but wherever I put it, it didn't work.
<?php
if (CurrentPageID() == "view") {
echo '<meta name="dc.title" content="' . CurrentPage()->kitap_adi->CurrentValue . '">';
}
?>
Re: add meta from database to view pages
Posted: Sat Sep 07, 2024 1:16 am
by arbei
If you want to add meta tag, you should use Page_Head server event.
Re: add meta from database to view pages
Posted: Sat Sep 07, 2024 2:09 am
by mehmetbkm
It's very strange, I add the following value to the "Server Eventes -> Global -> All Pages -> Page_Head" section. When I look at the page source, I only see it in the standard index page, I cannot see it on the "view" pages.
The value I added:
<meta name="author" content="Foo Bar">
Re: add meta from database to view pages
Posted: Sat Sep 07, 2024 11:31 am
by arbei
Page_Head is fired in the Layout page, which means all pages with the <head> tag. Did you have any condition before outputting the meta tag? Post your complete code for discussion.
Re: add meta from database to view pages
Posted: Sat Sep 07, 2024 4:20 pm
by mehmetbkm
You are completely right, it's my fault, it's working.