SEF URLs parameters and slug

Status
Not open for further replies.
Hello,

I am trying to get URL rewriting working properly on my J! 3.4.4 and Fabrik 3.3.2

My Fabrik SEF params are :
- prefix menu title : yes
- table name in forms : yes
- detail url format : ID-Table-Slug

My J! SEF params are :
- URL rewriting : Yes
- Apache rewriting : yes
- URL suffix : yes

I chose a slug element in my list but I am still getting URLs such as :
http://www.my-website/my-menu/details/listID/rowID.html

Whereas I should have :
http://www.my-website/my-menu/details/listID/my-slug-element-value-for-this-row.html

Do you have an idea of what is wrong with my params ?

Thanks for any help
Theo
 
Also I tried different things to set up my links :

- if I use the param "link to details" in elements it gives me links such as : http://www.my-website/my-menu/form/listID/my-slug-element-value-for-this-row.html
Not to bad, but it links to the form instead of the detail page.

- if I add a custom link in the elements params, I'm back to links such as : http://www.my-website/my-menu/details/listID/rowID.html

- if I remove both parameters above (link to details OFF + no custom link in element params) and add a link directly in the template, I get : http://www.my-website/my-menu/details/listID/rowID.html

Of course, for duplicate content matters, it is important to have the same URL in every cases : links in fabrik component but also in J! modules, content, etc...
 
If you are using Fabrik's global SEF options, then these are only applicable in conjunction with the sef404 component. Do you have that installed?
Do you have any other sef components installed?
For me with just the standard Joomla SEF and your settings I'm getting details views written:

http://site.com/test-list/details/1/1-test.html
 
If you are using Fabrik's global SEF options, then these are only applicable in conjunction with the sef404 component. Do you have that installed?
- Yes, I tried also with sh404sef version 4.4.6 (latest free version), and I tried it with "use Joomla router" param otherwise all my pages go blank...
with this setup I get the exact same result than without sh404sef... except I can get other interesting SEO features.

Do you have any other sef components installed?
- Just sh404sef

For me with just the standard Joomla SEF and your settings I'm getting details views written: http://site.com/test-list/details/1/1-test.html

- Strange... did you try with a non-rewritten link in the template or a link in a module / content to see if it is well rewritten ?
I am not using elements parameters to setup links because I need the same elements to be clickable in frontend and not clickable in backend... and I don't want to duplicate all my lists just for that... (29 lists...)... that's why all elements links are disabled by default and I use different templates everytime it's possible.
 
Last edited:
Well... still not there... Maybe my links should be different... ?
I use links in the template like :
Code:
<a href="index.php?option=com_fabrik&view=details&formid=21&rowid=<?php echo $this->_row->data->fk_mylist___id_raw;?>&Itemid=199">
                    <?php echo $this->_row->data->fk_mylist___titre_raw;?>
                </a>
 
hi Have you tried using JRoute to build the links?

so for your example:

PHP:
<a href="<?php echo JRoute::_('index.php?option=com_fabrik&view=details&formid=21&rowid=' . $this->_row->data->fk_mylist___id_raw . '&Itemid=199');?>">
                    <?php echo $this->_row->data->fk_mylist___titre_raw;?>
                </a>

For me (without sef404 on) that works. So a URL that looks like

index.php?option=com_fabrik&view=details&formid=1&rowid=' . $this->_row->data->fk_mylist___id_raw . '&Itemid=199

is converted to :

 
Hi
What I have been able to do is for the form and details views, set a canonical link in the document head, so whilst the URL may be different there is a single one defined for the form or details view. According to Mr Google https://support.google.com/webmasters/answer/66359?hl=en and https://support.google.com/webmasters/answer/139066?hl=en&rd=1 this should address any SEO issue relating to duplicate content.

To get this to work you will need to update from github.
For reference the commits that implemented this feature were:
https://github.com/Fabrik/fabrik/commit/bd267e1c28ccf93c3979257b962aa3984f1ad449
and
https://github.com/Fabrik/fabrik/commit/bd267e1c28ccf93c3979257b962aa3984f1ad449
 
Thank you Rob for this workaround... not perfect but still better than before. ;-)

Still, could you apply the same treatment with the canonical URL than with the slug : remove special characters, blanks changed for "-", lowercase...
For example, if a slug is built on a title "My beautiful trip", it will go :
- /trips/details/21/5-my-beautiful-trip.html with the slug
and
- /trips/details/21/5-%20My%20beautiful%20trip%20.html with the canonical tag
 
Also, I had a go with a recent version of sh404sef, and you're not far from having a working sh404sef plugin, you should :
- change JParameter for Jregistry as stated here : http://fabrikar.com/forums/index.ph...rking-sh404sef-plugin-for-fabrik.25508/page-2 (line 313 of the sef ext file)
- take the link Itemid (= menu id) into account when building a sef link (so that every detail link would take the menu alias in the URL)
... but it may seem easier than it really is... ;-)
 
I think I also found a better way to implement custom links in templates than using JRoute :
1 - we can set up the custom details URL in the list params Details > Links > custom details URL
Like this : index.php?option=com_fabrik&view=details&formid=your-form-ID&rowid={slug}&Itemid=your-menu-ID
2 - then, anytime it's possible, set up your links in the template files like this : <a href="<?php echo $this->_row->data->fabrik_view_url;?>">

That way, later on (for example if you change the menu ID), it will be possible to modify all the links in one go directly from the list params instead of going through every template file.

It is also possible to use this directly in the template file :
<a href="index.php?option=com_fabrik&view=details&formid=21&rowid=<?php echo $this->_row->data->slug;?>&Itemid=199">
... but we're loosing the possibility for direct changes from the list params.

Maybe you could use this $this->_row->data->slug for the canonical tag ?
 
Hello,
That sounds like a good way forward as well.
During my testing I was seeing the slug being used in the canonical links.
 
Mmmmhh... step forward but not good enough... and the slug still isn't used on my site's canonical links...
Then we still have the breadcrumb and other many default links that keep the /details/formID/detailID.html style... not easy to go through each of them...
I made a full Fabrik travel site and I think it's really important to have nice sef URLs for a frontend use.

Is adding the slug to the Joomla URL Router something doable ?
If yes, I can help financially with the time spent on a dev, just please tell me how much/long it could take.
 
Last edited:
And same question for the lists URL :
- if I link them to a menu they go : my-menu-alias.html
- if I use a custom link (exact same link than the menu including the menu Itemid), they go : my-menu-alias/list/listID.html
 
Hi
Routing is horrifically complicated in Joomla, so rather than committing something to github which might possibly break a lot of people's sites, I'd sooner that we test this manually. So could you make a copy up of :
components/com_fabrik/router.php

Then edit router.php and replace its code with:

PHP:
<?php
/**
 * build route
 *
 * @package     Joomla
 * @subpackage  Fabrik
 * @copyright   Copyright (C) 2005-2013 fabrikar.com - All rights reserved.
 * @license     GNU/GPL http://www.gnu.org/copyleft/gpl.html
 */

// No direct access
defined('_JEXEC') or die('Restricted access');

/**
 * if using file extensions sef and htaccess :
 * you need to edit your .htaccess file to:
 *
 * RewriteCond %{REQUEST_URI} (/|\.csv|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$  [NC]
 *
 * otherwise the csv exporter will give you a 404 error
 *
 */

/**
 * build route
 *
 * @param   object  &$query  uri?
 *
 * @return  array url
 */
function fabrikBuildRoute(&$query)
{
    $segments = array();
    $app = JFactory::getApplication();
    $menu = $app->getMenu();

    if (empty($query['Itemid']))
    {
        $menuItem = $menu->getActive();
        $menuItemGiven = false;
    }
    else
    {
        $menuItem = $menu->getItem($query['Itemid']);
        $menuItemGiven = true;
    }

    // Are we dealing with a view that is attached to a menu item https://github.com/Fabrik/fabrik/issues/498?
    $hasMenu = _fabrikRouteMatchesMenuItem($query, $menuItem);

    if ($hasMenu)
    {
        unset($query['view']);

        if (isset($query['catid']))
        {
            unset($query['catid']);
        }

        if (isset($query['layout']))
        {
            unset($query['layout']);
        }

        unset($query['id']);

        return $segments;
    }

    if (isset($query['c']))
    {
        // $segments[] = $query['c'];//remove from sef url
        unset($query['c']);
    }

    if (isset($query['task']))
    {
        $segments[] = $query['task'];
        unset($query['task']);
    }

    if (isset($query['view']))
    {
        $view = $query['view'];
        $segments[] = $view;
        unset($query['view']);
    }
    else
    {
        $view = '';
    }

    if (isset($query['id']))
    {
        $segments[] = $query['id'];
        unset($query['id']);
    }

    if (isset($query['layout']))
    {
        $segments[] = $query['layout'];
        unset($query['layout']);
    }

    if (isset($query['formid']))
    {
        $segments[] = $query['formid'];
        unset($query['formid']);
    }

    // $$$ hugh - looks like we still have some links using 'fabrik' instead of 'formid'
    if (isset($query['fabrik']))
    {
        $segments[] = $query['fabrik'];
        unset($query['fabrik']);
    }

    if (isset($query['listid']))
    {
        if ($view != 'form' && $view != 'details')
        {
            $segments[] = $query['listid'];
        }

        unset($query['listid']);
    }

    if (isset($query['rowid']))
    {
        $segments[] = $query['rowid'];
        unset($query['rowid']);
    }

    if (isset($query['calculations']))
    {
        $segments[] = $query['calculations'];
        unset($query['calculations']);
    }

    if (isset($query['filetype']))
    {
        $segments[] = $query['filetype'];
        unset($query['filetype']);
    }

    if (isset($query['format']))
    {
        // Was causing error when sef on, url rewrite on and suffix add to url on.
        // $segments[] = $query['format'];

        /**
        * Don't unset as with sef urls and extensions on - if we unset it
        * the url's prefix is set to .html
        *
        *  unset($query['format']);
        */
    }

    if (isset($query['type']))
    {
        $segments[] = $query['type'];
        unset($query['type']);
    }

    // Test
    if (isset($query['fabriklayout']))
    {
        $segments[] = $query['fabriklayout'];
        unset($query['fabriklayout']);
    }

    return $segments;
}

/**
 * Ascertain is the route that is being parsed is the same as the menu item desginated in
 * its Itemid value.
 *
 * @param $query
 * @param $menuItem
 *
 * @return bool
 */
function _fabrikRouteMatchesMenuItem($query, $menuItem)
{
    if (!$menuItem instanceof stdClass || !isset($query['view']))
    {
        return false;
    }
    $queryView = JArrayHelper::getValue($query, 'view');
    $menuView = JArrayHelper::getValue($menuItem->query, 'view');

    if ($queryView !== $menuView)
    {
        return false;
    }
    unset($query['Itemid']);

    switch ($queryView)
    {
        case 'list':
            if (!isset($query['listid']))
            {
                $query['listid'] = $query['id'];
                unset($query['id']);
            }

            break;
    }
   
    return $query === $menuItem->query;

    return true;
}

/**
 * parse route
 *
 * @param   array  $segments  url
 *
 * @return  array vars
 */

function fabrikParseRoute($segments)
{
    // $vars are what Joomla then uses for its $_REQUEST array
    $vars = array();
    $view = $segments[0];

    if (strstr($view, '.'))
    {
        $view = explode('.', $view);
        $view = array_shift($view);
    }

    /**
    * View (controller not passed into segments)
    *
    * $$$ hugh - don't use FArrayHelper::getValue() here, use original JArrayHelper.  Don't ask.
    * Well, since you asked, some users are reporting issues with the helper not having been
    * loaded (some bizarre 3rd party system plugin doing funky things), and since we don't need
    * what our wrapper does for this simple usage ... yes, we could specifically load our helper here,
    * and (dear reader) if you wanna do that be my guest.
    */

    switch ($view)
    {
        case 'form':
        case 'details':
        case 'emailform':
            $vars['view'] = $segments[0];
            $vars['formid'] = JArrayHelper::getValue($segments, 1, 0);
            $vars['rowid'] = JArrayHelper::getValue($segments, 2, '');
            $vars['format'] = JArrayHelper::getValue($segments, 3, 'html');
            break;
        case 'table':
        case 'list':
            $vars['view'] = JArrayHelper::getValue($segments, 0, '');
            $vars['listid'] = JArrayHelper::getValue($segments, 1, 0);
            break;
        case 'import':
            $vars['view'] = 'import';
            $vars['listid'] = JArrayHelper::getValue($segments, 1, 0);
            $vars['filetype'] = JArrayHelper::getValue($segments, 2, 0);
            break;
        case 'visualization':
            $vars['id'] = JArrayHelper::getValue($segments, 1, 0);
            $vars['format'] = JArrayHelper::getValue($segments, 2, 'html');
            break;
        default:
            break;
    }

    return $vars;
}

After that change, for me, when I add a link such as :

Code:
<a href="index.php?option=com_fabrik&amp;view=list&amp;id=1&amp;Itemid=111">routed link</a>

And my menu item 111 points to list id 1, then the url is converted to the same alias as the menu link's url.

You might also want to add an ftp account to the dev site's "My details" form, so I can test things directly there. I'd like to figure out why you don't see the slugs in the canical link, as I still do. So also let me know which list you were looking at with respect to those links.
 
Hi Rob, and thanks for working on this !

I updated router.php with your changes.

You can see this working on the list 8 (Destinations). You should still have access to my dev site.
In the front it's here : Guide de voyage > Destinations > then look at any detail page in this list.

The list link is now working (see the top of a Destination detail page)
There is a still problem with the breadcrumb, I don't know how Joomla handles this... I'll have a look.

The canonical tag isn't working.

I requested a FTP access for you for this specific site.
 
Thanks for adding the site details.

I believe I have fixed the router bread crumb issue. I've updated the file on your test site. If you could check to see that it doesn't produce inadvertent routing I can commit those changes to the main code base.

For the canonical links, I see:

<link rel="canonical" href="/guide-voyage/destinations/details/8/10-Knysna.html" /> listed on the details page.

Perhaps you were looking at the list page for the canonical link? If so I have now added canonical links for list views as well.
 
I fact, the breadcrumb issue is gone, thanks !
Unfortunately, is canonical link pb is still here... maybe the "Knysna" page is a bad example because the title has no space nor special character...
please try this one instead (title = R?serve de Botlierskop] : /guide-voyage/destinations/details/8/9.html
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top