我有一个连接到MySQL数据库的PHP脚本,并从其中提取信息并将其加载到一个可搜索的表中。如果我加载localhost/testphp.php
一切都很好,一切都很好,但我正在尝试将该页面添加到Drupal8中,但我不确定最好的方法。因为当您在Drupal中创建页面时,它似乎不会运行PHP代码。
下面基本上就是我写的东西。
<table id="myTable">
<thead>
<tr class="header">
<th style="width:20%;">Drawing ID</th>
<th style="width:25%;">Sheet Number</th>
<th style="width:25%;">Revision</th>
<th style="width:30%;">First Title Line</th>
<th style="width:30%;">Second Title Line</th>
<th style="width:30%;">Third Title Line</th>
<th style="width:30%;">Fourth Title Line</th>
<th style="width:30%;">Notes</th>
</tr>
</thead>
<tbody>
<?php
require '../scripts/connect.php';
$sql = "SELECT * FROM drawing_data";
$result = mysqli_query($dbc, $sql) or die("Bad Query: $sql");
while($row = mysqli_fetch_assoc($result)) {
echo"<tr><td>{$row['First Part']} / {$row['Second Part']} / {$row['Third Part']} / {$row['Fourth Part']} </td><td>{$row['Sheet Number']}</td><td>{$row['Revision']}</td><td>{$row['First Title Line']}</td><td>{$row['Second Title Line']}</td><td>{$row['Third Title Line']}</td><td>{$row['Fourth Title Line']}</td><td>{$row['Notes']}</td><tr>";
}
?>
</tbody>
</table>
</div>我刚开始使用Durpal,已经很长时间没有做过web dev类型的东西了。所以可能有更好的方法来解决它,但我觉得我不够聪明,不能自己解决这个问题。
发布于 2019-08-28 19:34:41
搜索如何在Drupal8中创建自定义页面。网上有很多关于这个主题的教程。也就是说。
https://www.drupal.org/docs/8/creating-custom-modules/create-a-custom-page
。。或者..。
https://www.anubavam.com/blogs/how-to-develop-custom-page-on-drupal-8
或者找一些其他的,也许是视频教程。
基本上,您必须定义一个路由,然后为该路由调用控制器。使用drupal的主题系统并将html放入twig模板中也会很好。
https://stackoverflow.com/questions/57670359
复制相似问题