douqiandai4327 2014-04-03 17:09
浏览 38

在joomla中是否可以将包含变量的代码从一个覆盖复制并粘贴到另一个覆盖?

I want to adapt my tags result page (default_items.php) so that instead of only showing the articles title it also shows the core article introduction as shown on a category blog page (blog.php).

I thought I'd do this using overrides by copying the code that outputs the article introduction (round about line 82)

<?php
   $this->item = &$item;
   echo $this->loadTemplate('item');
?>

into the default_items.php file.

All I get is the following error 500 - Layout default_item not found.

Does anyone know how to do this/what the problem is with my approach? Do I just need to define the variables in the default_items.php?

I'm using Joomla 3.2

  • 写回答

1条回答 默认 最新

  • dongshenghe1833 2014-04-03 19:03
    关注

    If I understand you correctly, you have overridden the tag view ( /components/com_tags/views/tag/tmpl/ ). You are in the default_item.php - file in this override, and from here you are calling

    <?php
       $this->item = &$item;
       echo $this->loadTemplate('item');
    ?>
    

    What Joomla does now is to try to load i file default_item_item.php. Since this file does not exist on the path, (the path includes /components/com_tags/views/tag/tmpl, and your override /templates/yourtemplate/html/com_tags/tag ) a 500-error is thrown.

    What you should do is to se what data is loaded in the items. Try

    <?php
    print_r($this->item); 
    ?>
    

    This will show whatever data is available in the current view (you could also try print_r($this) to see if there are other interesting variables in the current view object that you would like to use. )

    If the data you need ( the introtext? ) is not available in $this->item, then there are a couple of solutions to load more data:

    • Load the data directly in the view. This is quick and dirty, but contradicts the mvc-model.
    • Write a content-plugin and load the data in the onContentPrepare - function. This function is called in /component/com_tags/views/tag/view.html.php

    The procedure to load the data is similar in both occations. Tell me if you need more help with it...

    regards Jonas

    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料