2014-05-25 44 views
0

大家好,並提前感謝您的幫助,可以給我。在阿賈克斯模塊joomla網址sef

我正在創建一個joomla模塊來顯示通過ajax的文章,我差不多完成了,我有這個url的問題。

問題是模塊通過ajax調用search.php。除了url之外,所有回報都很好。

返回我的網址是: /www.miste.com/modules/mod_mymodule/index.php?option=com_content &視圖=文章& ID = 12:MI-標題,文章& CATID = 10 & ITEMID = 107

正確的做法是: /www.miste.com/index.php?option=com_content &視圖=文章& ID = 12:MI-標題-文章& CATID = 10 & ITEMID = 107

我的部分代碼如下:

if (!$_GET) exit; 
if (!defined("_JEXEC")) define("_JEXEC", "\r\n") or die('Restricted access'); 

define('DS', DIRECTORY_SEPARATOR); 
define('JPATH_BASE', dirname(dirname(dirname(__FILE__)))); 
require_once (JPATH_BASE .DS.'includes'.DS.'defines.php'); 
require_once (JPATH_BASE .DS.'includes'.DS.'framework.php'); 
require_once (JPATH_BASE.DS.'components'.DS.'com_content'.DS.'helpers'.DS.'route.php'); 
require_once (JPATH_BASE.DS.'components'.DS.'com_content'.DS.'router.php'); 
require_once (dirname(__FILE__).'/helper.php'); 

/** CREATE THE APPLICATION**/ 
$mainframe = JFactory::getApplication('site'); 
/**INITIALISE THE APPLICATION**/ 
$mainframe->initialise(); 

if(modFpncrFilterArticlesHelper::validaSelect($selectDestino) && modFpncrFilterArticlesHelper::validaOpcion($opcionSeleccionada)) 
    { 
    $tabla=$listadoSelects[$selectDestino]; 

     $db = JFactory::getDbo(); 
     $query = $db->getQuery(true) 
      ->select('id, title, alias, catid') 
      ->from('#__content') 
      ->where('catid="'.$opcionSeleccionada.'"') 
      ->where('state=1'); 
     $db->setQuery($query); 
     $allarticles = $db->loadObjectList('id'); 

    // Comienzo a imprimir el select 
    $InputsArticles = ''; 
     foreach ($allarticles as $article){ 

$catslug = $article->catid; 
$slug = $article->id.':'.$article->alias; 
$link = JRoute::_(ContentHelperRoute::getArticleRoute($slug, $catslug));    

$UrlArticle = JRoute::_(ContentHelperRoute::getArticleRoute($article->id.":".$article->alias, $article->catid), true); 
       $InputsArticles .= "<option value='". $link ."'>".$article->title."</option>"; 
      } 
     $InputsArticles = $InputsArticles; 
    } 
    ?> 
<select name="<?php echo $selectDestino; ?>" id="<?php echo $selectDestino; ?>" onChange='cargaContenido(this.id)'> 
    <option value="0"><?php echo $article_label_active; ?></option> 
    <?php echo $InputsArticles; ?> 
</select> 
<input type="button" name="go" value="<?php echo $button_label; ?>" onclick="check_send();" class="btn btn-success" id="send"> 

在此先感謝您的幫助,你可以給我

回答

0

我用了一些這樣的事時,我已經開發的模塊。

$ article-> slug = $ article-> id。':'。$ article-> alias; $ article-> catslug = $ article-> catid? $ article-> catid。':'。$ article-> category_alias:$ article-> catid;

echo JRoute :: _(ContentHelperRoute :: getArticleRoute($ article-> slug,$ article-> catslug));

這是在循環內部。

+0

嗨,謝謝你的回覆。 問題是URL顯示模塊的路徑,當它不應該。 – user3673405

+0

在應用我的代碼後仍然顯示? – user3118004

0

您是否嘗試過不使用contenthelperroute?從模塊調用時可能不適用。嘗試:

$link=JRoute::_("index.php?option=com_content&view=article&id={$article->id}&catid={$article->catid}"); 

而且,看起來有些混亂有在你的代碼,你有兩個$鏈接和$ UrlArticle - 變數,但後者從未使用過(在你的代碼片段反正)