1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

Add meta Property to Head from Fabrik Element?

Discussion in 'Community' started by talkinggoat, May 13, 2019.

  1. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    @sunnyjey you've reached a point where I can't help on a free, ad-hoc basis. If you'd like to talk to us about a direct support arrangement, with a "bucket" of hours each month you can draw on for support, let me know.

    -- hugh
  2. sunnyjey

    sunnyjey Active Member

    Level: Community
  3. sunnyjey

    sunnyjey Active Member

    Level: Community
    Instead of using php_event list plugin, I used these codes into my custom template list & with the help of Jsitemap Pro I could finally succeeded in generating dynamic metaTags based on Filters.

    BUT got another big problem.

    $mydoc->addCustomTag('<link rel="canonical" href="www.mydomain/canonical/url" />');

    When I am trying to get canonical url by using above syntax, I get my custom canonical url.

    BUT, fabrik also adds another default canonical url at the top of my custom canonical url. It is generating two URLS
    1. www.mydomain/my-menu-url (<link rel="canonical" href="/my-menu-url" /> eg. if my menu name is say hotels-listing, fabrik adds www.mydomain.com/hotels-listing/)
    2. www.mydomain/canonical/url
    I guess, Fabrik is forcing Default canonical url from this file


    Code (Text):
    * Set the canonical link - this is the definitive URL that Google et all, will use
         * to determine if duplicate URLs are the same content
         * @throws Exception
        public function setCanonicalLink()
            if (!$this->app->isAdmin() && !$this->isMambot)
                $url = $this->getCanonicalLink();

                // Set a flag so that the system plugin can clear out any other canonical links.
                $this->session->set('fabrik.clearCanonical', true);
                $this->doc->addCustomTag('<link rel="canonical" href="' . htmlspecialchars($url) . '" />');
    How do I remove the default canonical URL. Is there any way I can remove $url = $this->getCanonicalLink(); ? Is layout override for /components/com_fabrik/views/list/view.html.php possible ?

    Regards & Thanks

    (NB: It looks Hugh is busy somewhere in his work, as he has not yet PM me)
    Last edited: Feb 14, 2020 at 4:54 AM
  4. lousyfool

    lousyfool Active Member

    Level: Community
    It works for me: just a single canonical URL when using my code in my custom list template, no further action required. I don't know Jsitemap, perhaps it is involved here, too.

    However, please do a count of both opening and closing brackets in your code line. Resulting action may help.

    Use this: https://fabrikar.com/quote-request
  5. sunnyjey

    sunnyjey Active Member

    Level: Community
    Thank you once again for your reply. I have spent many hours to address this issue.

    If possible can you please share your code for canonical URL.
  6. lousyfool

    lousyfool Active Member

    Level: Community
    Just checked, can't find or recreate the exact code without spending more time on it, it's buried in some older backups.

    But, as far as I remember, and as elsewhere in J!, in Fabrik lists you'll just need to get rid of the "original" canonical URL, then add the new one. Along the lines of: get head data, loop through the relevant section, empty the value where rel="canonical" is part of the string, set head data again, then add your own tag.
  7. sunnyjey

    sunnyjey Active Member

    Level: Community
    Yes, you are right. We need to unset the default canonical first. I have uninstalled JSitemap Pro.

    Even tried following code to unset canonical in default.php of my custom list template:

    Code (Text):

    $doc = JFactory::getDocument();
    foreach ($doc->_links as $k => $array) {
    if ($array['relation'] == 'canonical') {
    But, it is not removing the www.mydomain.com/my-menu. It looks the unset for $this->getCanonicalLink(); is not working, like other MetaTags. If possible, please test it at your testing server to confirm this issue.

    Once again Thank you for your help.
  8. lousyfool

    lousyfool Active Member

    Level: Community
    Sorry, I'm with Hugh / @cheesegrits here:

    So I'd say more on this and my code to follow once you have some arrangement.

Share This Page