×
Please submit new Bug Reports on GitHub: github.com/Jensen-Technologies/component-creator-issues/issues
Correct Route
Javier Mata Salazar
New Member
Posts: 5
7 år 5 måneder siden #1587
af Javier Mata Salazar
Correct Route blev oprettet af 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
Venligst Log på eller Opret en konto for at deltage i samtalen
Tid til at oprette siden: 0.045 sekunder