[英]Display Joomla module with php
extremelly need help with php request to database. 极需要有关PHP请求数据库的帮助。 I wrote a code which should display module in new php file
我写了一个代码,应该在新的php文件中显示模块
<?php $db = new mysqli('server', login', 'pass', 'db'); $query = 'SELECT * FROM k7c1b_modules WHERE id = "339"'; $result = $db->query($query); $row = $result->fetch_row(); echo $row; $result->close(); ?>
But as a result I see only message "Array". 但是结果是我只看到消息“ Array”。 If I write echo $row[1];
如果我写echo $ row [1]; I see module's Id.
我看到模块的ID。 But how to make my code display whole module?
但是如何使我的代码显示整个模块?
The row is an array. 该行是一个数组。 Access vars by column name like this:
通过列名访问var,如下所示:
echo $row['columnNameHere'];
If you want the module itself to display, I recommend just loading a module position instead. 如果要显示模块本身,建议您只加载模块位置。 Then you can assign whatever module(s) to that page.
然后,您可以将任何模块分配给该页面。 Will make it a lot easier if you want to change the module or unpublish it.
如果您要更改模块或取消发布它,将使其变得更加容易。
Make sure load plugin "Content - Load Modules" is enabled and in the PHP just put in: 确保已启用加载插件“内容-加载模块”,并且已在PHP中将其插入:
<?php echo JHtml::_('content.prepare', '{loadposition mijo-header}'); ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.