× Please submit new Bug Reports on GitHub: github.com/Jensen-Technologies/component-creator-issues/issues

Correct Route

7 Jahre 6 Monate her #1587 von Javier Mata Salazar
Correct Route wurde erstellt von Javier Mata Salazar
hi, i have a component and i use this route.php
<?php

/**
 * @version     1.0.1
 * @package     com_catalogo
 * @copyright   Copyright (C) 2014. Todos los derechos reservados.
 * @license     Licencia Pública General GNU versión 2 o posterior. Consulte LICENSE.txt
 * @author      Javier Mata <javimata@gmail.com> - http://www.javimata.com
 */
// No direct access
defined('_JEXEC') or die;

/**
 * @param	array	A named array
 * @return	array
 */
function CatalogoBuildRoute(&$query) {
    $segments = array();

    if (isset($query['task'])) {
        $segments[] = implode('/', explode('.', $query['task']));
        unset($query['task']);
    }
    if (isset($query['view'])) {
        $segments[] = $query['view'];
        unset($query['view']);
    }
    if (isset($query['id'])) {
        $segments[] = $query['id'];
        unset($query['id']);
    }
    if (isset($query['alias'])) {
        $segments[] = $query['alias'];
        unset($query['alias']);
    }
    unset($query['task']);
    unset($query['view']);    
    return $segments;

}

/**
 * @param	array	A named array
 * @param	array
 *
 * Formats:
 *
 * index.php?/catalogo/task/id/Itemid
 *
 * index.php?/catalogo/id/Itemid
 */
function CatalogoParseRoute($segments) {
    $vars = array();

    // view is always the first element of the array
    $vars['view'] = array_shift($segments);

    while (!empty($segments)) {
        $segment = array_pop($segments);
        if (is_numeric($segment)) {
            $vars['id'] = $segment;
        } else {
            $vars['task'] = $vars['view'] . '.' . $segment;
        }
    }

    return $vars;
}

The url that use in the view is like this:
index.php?option=com_productos&view=producto&id=' . (int)$item->id.'&alias='.$item->alias

and this create urls like this:
site.com/[CATEGORY-ALIAS]/producto/[PRODUCT-ID]/[PRODUCT-ALIAS]

This is ok (well... i dont like /producto/ )

and if i use this same route in a module create links like this:
site.com/component/productos/producto/[PRODUCT-ID]/[PRODUCT-ALIAS]

Can help me to fix this?
really i wanna urls (via the component and modules) like this:
site.com/[CATEGORY-ALIAS]/[PRODUCT-ALIAS]

or
site.com/[CATEGORY-ALIAS]/[PRODUCT-ID]/[PRODUCT-ALIAS]

thanks so much

Bitte Anmelden oder Registrieren um der Konversation beizutreten.

Ladezeit der Seite: 0.047 Sekunden
Powered by Kunena Forum

Wir verwenden eigene Cookies und Cookies von Drittanbietern, um Ihr Nutzererlebnis zu verbessern und Ihnen einen optimalen Service zu bieten. Wenn Sie die Website weiter nutzen, gehen wir davon aus, dass Sie mit unserer Cookie-Politik einverstanden sind.