by (450 points)
edited by
Hello, this is and update to my older question:

http://www.seotoaster.com/questions-and-answers/851/facebook-image-metatag

I managed to insert facebook image metatag directly in the  /seotoaster_core/application/layouts/scripts/layout.phtml file;
however, it looks like I can't get the $page:url value in it. The tag renders ok, but no image file name... Can you please help me out?

Here's the code with the minor change I made ( look for Facebook image meta to find the added tag):

<?php echo $this->doctype(); ?>

<!--[if IE 7 ]><html class="ie ie7" lang="<?php echo $this->htmlLang; ?>"> <![endif]-->
<!--[if IE 8 ]><html class="ie ie8" lang="<?php echo $this->htmlLang; ?>"> <![endif]-->
<!--[if IE 9 ]><html class="ie ie9" lang="<?php echo $this->htmlLang; ?>"> <![endif]-->
<!--[if !(IE)]><!-->
<html lang="<?php echo $this->htmlLang; ?>">
<!--<![endif]-->
    <head>
<?php echo $this->headMeta()->setIndent(8); ?>

        <?php echo $this->headTitle(); ?>

        <?php
        // link and script block start
        //adding canonical link

        $this->headLink()->setIndent(8)
            ->prependStylesheet($this->websiteUrl . 'system/js/external/fancybox/jquery.fancybox.css')
            ->prependStylesheet($this->websiteUrl . 'system/css/seotoaster-ui.css');

        $this->headLink()->headLink(array('rel' => 'canonical', 'href' => $this->canonicalUrl), 'PREPEND');

        if (Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_PAGE_PROTECTED)) {
            if (empty($this->bodyTag)) {
                $this->headLink()
                    ->prependStylesheet($this->websiteUrl . 'system/css/seotoaster.css')
                    ->prependStylesheet($this->websiteUrl . 'system/css/reset.css');
            } else {
                $this->headLink()
                    ->prependStylesheet($this->websiteUrl . 'system/css/seotoaster-reset.css');
            }
        }

        if (isset($this->minify) && $this->minify === true) {
            echo Tools_System_Minify::minify($this->headLink(), false);
        } else {
            echo $this->headLink();
        }

        $this->jQuery()
            ->uiEnable()
            ->addJavascriptFile($this->websiteUrl . 'system/js/external/fancybox/jquery.fancybox.js')
            ->addJavascriptFile($this->websiteUrl . 'system/js/external/jquery/plugins/mousewheel/jquery.mousewheel.min.js')
            ->addJavascriptFile($this->websiteUrl . 'system/js/external/jquery/plugins/cookie/jquery.cookie.js')
            ->addJavascriptFile($this->websiteUrl . 'system/js/external/smoke/smoke.min.js');

        $this->headScript()->setIndent(8)->setAllowArbitraryAttributes(true)
            ->prependFile($this->websiteUrl . 'system/js/internal/system.min.js');

        echo $this->jQuery();
        if (isset($this->minify) && $this->minify === true)  {
            echo Tools_System_Minify::minify($this->headScript());
        } else {
            echo $this->headScript();
        }
        // link and script block end
    // Facebook image meta
        echo '<meta property="og:image" content="'.$this->websiteUrl.'previews/'.$this->page->url.'.png" />';
        echo $this->placeholder('misc');
        echo isset($this->placeholder('seo')->seoHead) ? $this->placeholder('seo')->seoHead: '';
        ?>
   
    </head>
    <?php echo !empty($this->bodyTag) ? $this->bodyTag : '<body>'; ?>
        <?php echo isset($this->placeholder('seo')->seoTop) ? $this->placeholder('seo')->seoTop: ''; ?>
        <?php echo $this->layout()->content; ?>
        <?php echo isset($this->placeholder('seo')->seoBottom) ? $this->placeholder('seo')->seoBottom: ''; ?>
        <input type="hidden" id="website_url" value="<?php echo $this->websiteUrl; ?>" />
        <input type="hidden" id="current_theme" value="<?php echo $this->currentTheme; ?>" />
        <?php if(isset($this->sculptingReplacement)): ?>
            <!-- PRSCULPTING -->
            <script type="text/javascript" charset="utf-8">$(function() {var sculptingReplacement = <?php echo $this->sculptingReplacement; ?>;$.each(sculptingReplacement, function() {$('span.' + this.id).replaceWith(this.repl);})});</script>
            <!-- /PRSCULPTING -->
        <?php endif; ?>

        <?php
            /**
             * Plugins additional content
             */
            echo $this->placeholder('plugins');
        ?>

    </body>
</html>
related to an answer for: Facebook image metatag

1 Answer

by (1.1k points)
Hello carlo15,

Please change your line with this one:

echo '<meta property="og:image" content="' . $this->websiteUrl.'previews/' . rtrim($this->pageData['url'], '.html') . '.png" />';

In layout file, all information about current page stored in '$this->pageData'.

Now it should work.

Thank you,
Oleg
...