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

Correct Route

pred 7 rokmi 5 mesiacmi #1587 od Javier Mata Salazar
Correct Route bolo vytvorené 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

Prosím Prihlásiť alebo Registrácia pre zdieľanie konverzácie.

Čas vytvorenia stránky: 0.043 sekúnd
Funguje na Kunena fórum

We use cookies so that you can place orders and we can provide a better service. You can control the use of cookies at the individual browser level. If you reject cookies, you may still use our website, but your ability to use some features or areas of our website may be limited.