I have developed a classifieds ads website using joomla, with my main component being dj-classifieds. I am now want to use addthis sharing tools. for this, I need to include the facebook title tag in the head of my website. the title of course is dynamic and I need to use a php string to get the correct title for each page. I was able to do this inside my source file that control the item view page. indeed, using <?php echo $item_name ?>
inside my source file, I can display the title anywhere on the item view page.
What I trying to do is to generate the same title, but inside the file that controls my site's head. both file are located in different direction as follows (complete path, in the root directory): - item view source file is stored here : /components/com_djclassifieds/views/item/tmpl/default.php
- the head file is stored here: /templates/jm-joomclassifieds-ef4/tpl/blocks/head.php
After reading various solutions, I decided to include default.php file inside the head.php file and then to call echo, but it did not work.
This is my code: <meta property="og:title" content="<?php include( $_SERVER['DOCUMENT_ROOT'] . '/components/com_djclassifieds/views/item/tmpl/default.php' ); echo $item->name; ?>" />
What am I doing wrong? I am rather very new with php, so I will dearly appreciate if you can be explicit in your help.
for further detail, below is and exrtact of of each of the two files:
- the item view cource code (default.php: the extract below is from the beginning of the file up to the point where echo is called to generate the item title):
And this is the og tags that I am trying to write: ain the head.php file :
<!-- for Facebook -->
<meta property="og:title" content="<?php include( $_SERVER['DOCUMENT_ROOT'] . '/components/com_djclassifieds/views/item/tmpl/default.php' ); echo $item->name; ?>" />
<meta property="og:url" content="<?php echo 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; ?>" />
I will dearly appreciate the time that you will spend helping me out.