2013-03-04 75 views
0

我在自定義Joomla組件上設置了分頁。爲了避免頁面冗長的解釋,我們正在做一些錯綜複雜的iframe嵌入和前向掩蓋。這是組件前端的分頁。Joomla分頁URL不包含view = viewname

在我的iframe中,我有一個小狗列表(來自自定義組件)。它是分頁的。爲了使幼犬在iframe中正確顯示它有網址:

http://americasfavoritepuppybreeders.com/puppies/breed/labrador/page-2.html?tmpl=component&view=microsite

但是當我真正點擊分頁鏈接,第2頁上則丟棄該視圖=微型導致的問題。我怎樣才能調整這個,使它不會下降view = microsite?

原始URL是http://americasfavoritepuppybreeders.com/puppies/breed/labrador/page-1.html?tmpl=component&view=microsite

這個分頁的代碼是長,模型,視圖和view.html.php之間,似乎很難讓我發佈所有相關的代碼。這裏有一些雖然我一直在尋找。

任何想法或提示何處/如何做到這一點?

感謝 扎克

// Get the pagination request variables 
    $limit  = $app->input->get('limit', $params->get('display_num', 20), 'uint'); 
    $limitstart = $app->input->get('limitstart', 0, 'uint'); 

    $this->setState('puppies.limit', $limit); 
    $this->setState('puppies.limitstart', $limitstart); 

    // Load the parameters. 
    $this->setState('params', $params); 
    }   

/** Method to get a store id based on the model configuration state. **/ 
protected function getStoreId($id = '') 
    { 
    // Compile the store id. 
    $id .= ':' . $this->getState('puppies.breed_alias'); 
    $id .= ':' . $this->getState('puppies.limit'); 
    $id .= ':' . $this->getState('puppies.limitstart'); 
    $id .= ':' . serialize($this->getState('puppies.filter')); 
    $id .= ':' . $this->getState('puppies.featured'); 

    return parent::getStoreId($id); 
    } 

/** Method to get a JPagination object for the data set. **/ 
public function getPagination() 
    { 
    // Create the pagination object. 
    $limit = (int) $this->getState('puppies.limit'); 
    $page = new JPagination($this->getTotal(), $this->getStart(), $limit); 

    return $page; 
    } 

/** Method to get the total number of items for the data set. **/ 
public function getTotal() 
    { 
    return $this->items_total; 
    } 

/** Method to get the starting number of items for the data set. **/ 
public function getStart() 
    { 
    $start = $this->getState('puppies.limitstart'); 
    $limit = $this->getState('puppies.limit'); 
    $total = $this->getTotal(); 
    if ($start > $total - $limit) 
     { 
     $start = max(0, (int) (ceil($total/$limit) - 1) * $limit); 
     } 

    return $start; 
    } 

同樣,這裏的代碼的一部分,但我不知道該怎麼開始張貼了一個答案,所以請我將張貼任何代碼,但是點我在正確的方向, 謝謝。

回答

1

在該視圖的「adminform」底部的某處,應該有提交視圖/控制器/令牌的所有隱藏輸入。

事情是這樣的:

  <input type="hidden" name="option" value="com_puppies" /> 
      <input type="hidden" name="view" value="microsite" /> 
      <input type="hidden" name="task" value="" /> 
      <input type="hidden" name="boxchecked" value="0" /> 
      <inupt type="hidden" name="controller" value="microsite" /> 
      <input type="hidden" name="filter_order" value="<?php echo $this->escape($this->state->get('list.ordering')); ?>" /> 
      <input type="hidden" name="filter_order_Dir" value="<?php echo $this->escape($this->state->get('list.direction')) ?>" /> 
      <?php echo JHtml::_('form.token'); ?> 

隨意刪除(如果你處理的是不同的即那些filter_order),您將不能使用輸入。重要的是視圖輸入。另外,如果您沒有使用該視圖的控制器(也就是說,您正在使用該組件的默認控制器),請將控制器輸入輸出。

+0

我想我可能錯過了一個文件,當創建這個新的視圖,但看着其他的我可以告訴這肯定會解決我的問題..一旦我設置該視圖的管理表單。 – 2013-03-04 00:41:36

+0

應該在管理員目錄下還是在組件目錄下? – 2013-03-04 00:44:27

+0

很高興知道!不確定這是否會對您有所幫助,但我們始終都會使用此組件創建者。它爲我們節省了一大筆時間來設置最初的文件結構..我知道你知道痛苦..任何與Joomla合作的人都可以:)。 http://www.notwebdesign.com/joomla-component-creator/。 – dcasadevall 2013-03-04 00:44:55

0

您可以給此鏈接http://americasfavoritepuppybreeders.com/puppies/breed/labrador/page-1.html?tmpl=component&view=microsite沒有SEF嗎?你可以嘗試創建文件/templates/{$your_template}/html/pagination.php這樣的代碼

<?php 
function pagination_item_active(&$item){ 
    $getData = new JInput($_GET); 
    $view = $getData->get('view','','string'); 
    $link_part = ($view == 'microsite' ? '&view=microsite' : ''); 
    $link = "<a title=\"" . $item->text . "\" href=\"" . $item->link.$link_part . "\" class=\"pagenav2\">" . $item->text . "</a>"; 
    return $link; 
} 

function pagination_item_inactive(&$item){ 
    return "<span class=\"pagenav\">" . $item->text . "</span>"; 
} 

此外,我認爲你的問題中不正確的鏈接。你如何得到這個鏈接http://americasfavoritepuppybreeders.com/puppies/breed/labrador/page-1.html?tmpl=component&view=microsite?如果您使用view = microsite的ready鏈接,請嘗試在管理面板的視圖(微型網站)上創建鏈接並使用此鏈接。