默认parent::display($tpl);
加载components/com_my_component/views/my_component/tmpl/default.php
,但在某些情况下,我需要加载位于default.php
附近的同一文件夹中的其他php文件(例如components/com_my_component/views/my_component/tmpl/lol.php
)。如何从view.html.php
。
P.S。
尝试加载loadTemplate
和setLayout
方法但没有运气。
答案 0 :(得分:11)
自己解决问题。需要使用方法setLayout并注意输入语法
$this->setLayout('dafault:lol');
parent::display($tpl);
答案 1 :(得分:3)
默认情况下,joomla会在URL中查找Sub SOC_work()
'Trying to sort each of the disciplines further, by Stage of Construction
Dim ar_SOC() As Variant
Dim int_NumRows As Long
Dim i_counter As Long
Dim j_Counter As Long
Dim lite As Range
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Sheets("AVEVA_PBOM_PARTS").Select
'Redimension the array size to the amount of parts in the PBOM
int_NumRows = ActiveSheet.UsedRange.Rows.count - 1
ReDim ar_SOC(int_NumRows, 3)
'now assignt he range into the array space
lite = Range("AA2", Range("AA2").End(xlDown))
ar_SOC[][1]=lite
End Sub
关键字,以决定要显示的布局。如果此变量为空或不存在,则将加载layout
布局。
通过编辑tmpl/default.php
文件,您可以使用JView API设置默认布局,例如: $this->setLayout('lol')
会使网址view.html.php
等同于example.com/yourview
。
但是,仅此更改将导致Joomla覆盖其默认行为,以便忽略example.com/yourview?layout=lol
请求。这意味着请求layout
也会显示example.com/yourview?layout=lmao
= example.com/yourview
您可以通过在example.com/yourview?layout=lol
函数周围添加条件来轻松解决此问题,这样只有当setLayout
关键字不存在时,您才会将默认布局设置为layout
,例如< / p>
lol
答案 2 :(得分:1)
我一直回到这里,我还没有找到令人满意的解决方案。
对我来说,从J1.5到J3.4的工作原理一直是在view.html.php中设置$ tpl变量
如果$ tpl为空或“”,则默认显示tmpl / default.php。
如果您将$ tpl更改为字符串,例如$ tpl =“stacker”然后它将查找并显示tmpl / default_stacker.php
我在MVC中早些时候看到了各种不同的理论,因此它不需要default_ pretext。例如TMPL / stacker.php 没有人对我有用。