2009-07-24 70 views
1

我需要修改joomla模塊的HTML結構。我想創建我的自定義模塊,我需要在其內容下方顯示標題。 這是本HTML是默認格式(四捨五入):修改Joomla自定義模塊的HTML結構

<div class="module_clipon"> 
<div> 
    <div> 
    <div> 
     <h3>Right Module</h3> 
     <p>This is the content</p>     
    </div> 
    </div> 
</div> 
</div> 

我需要上述HTML要像:

<div class="module_clipon"> 
    <p>This is the content</p> 
    <h3>This is the title</h3> 
</div> 

基本上以使模塊內容下面的標題。在Joomla中操作模塊的HTML的方式是什麼?我相信它可以通過使用modChrome。如果有人有一個簡單的實施解決方案,請幫助。

回答

1

您確實需要通過自定義模塊chrome來處理這個問題。在您的模板文件夾中,如果文件夾不存在,請創建一個html文件夾。在此文件夾中,創建文件modules.php。然後用這個代碼填充它:

<?php 

defined('_JEXEC') or die; 

function modChrome_titleonbottom($module, &$params, &$attribs) 
{ 
    echo '<p>' . $module->content . '</p>'; 
    echo '<h3>' . $module->title . '</h3>'; 
} 

最後,返回到您的模板,以這種鉻適用於您的模塊的位置:

<div class="module_clipon"> 
    <jdoc:include type="modules" name="left" style="titleonbottom"/> 
</div> 

使用任何模塊位置的名字,你在name參數需要。請注意,style參數與modChrome_函數名稱匹配。

欲瞭解更多信息: http://docs.joomla.org/What_is_module_chrome%3F http://docs.joomla.org/Applying_custom_module_chrome

+0

謝謝jlleblanc,你的迴應很有幫助。但是我需要在同一個模塊位置有其他模塊,其上下都有默認的四捨五入佈局(4 div div wrapping)。任何猜測如何做到這一點? – Cruising2hell 2009-07-30 19:18:59

2

@ Cruising2hell如果你想擁有的同一位置上的替代模塊佈局你嘗試使用模塊後綴PARAMS?像這樣..

<?php 

defined('_JEXEC') or die; 

function modChrome_titleonbottom($module, &$params, &$attribs) 
{ 
    switch($params->get('moduleclass_sfx')) : 
    //My type of module 
    case 'titleonbottom': 
     echo '<p>'. $module->content . '</p>'; 
     echo '<h3>' . $module->title . '</h3>'; 
    break; 
    default: 
    //Normal 
     echo '<h3>' . $module->title . '</h3>'; 
     echo '<p>'. $module->content . '</p>'; 
    break; 
    endswitch; 

} 
+0

非常感謝......解決了我需要的內容..雖然我有另一個查詢,是否有可能爲文章組件提供類似的解決方案。如果我可以使用不同的HTML佈局來實現文章,以在Joomla中實現「組合」類頁面來顯示項目,同時在一個頁面上定期發佈文章。我不知道,請建議什麼是最好的解決方案,有一個項目頁面,可以輕鬆地顯示項目。它必須包含縮略圖,項目細節和一些客戶信息。 – Cruising2hell 2009-08-02 16:11:05

0

我不能說它是一個問題。

轉到您的主CSS文件,插入下面的代碼:

.module_clipon h3 { 
    position: absolute; 
    margin-top: 100px; 
    } 

/* put a right height value where your h3 module header reach the bottom of the module content */ 
0

我不能稱之爲問題。

去你的主css文件,並插入下面的代碼:

.module_clipon h3 { 
     position: absolute; 
     margin-top: 100px; 
} 

/*把合適的高度值,其中您H3模塊頭部到達模塊內容*/

:-)底部

0

可以修改$ module-> content的返回嗎?因爲,如果該模塊是一種類型的菜單,渲染是:

<ul class="nav menu"><li>...</li></ul>

和例如如果我需要把一類=「列表內聯」的<ul>內刪除導航和ul標籤的菜單樣式。