×
Please submit new Bug Reports on GitHub: github.com/Jensen-Technologies/component-creator-issues/issues
Correct Route
Javier Mata Salazar
Nouveau membre
Posts: 5
il y a 7 ans 6 mois #1587
par Javier Mata Salazar
Correct Route a été créé par Javier Mata Salazar
hi, i have a component and i use this route.php
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
<?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
Connexion ou Créer un compte pour participer à la conversation.
Temps de génération de la page : 0.049 secondes