用php或Laravel创建WordPress的最好方法是什么?
例如,如果我使用这个table=table_name,它应该从table_name获取所有记录,然后将其显示在前端的页面或帖子上,而不是像WordPress那样显示在后端。
任何示例代码或示例都是很好的入门工具。
发布于 2017-09-21 06:33:32
谷歌"Laravel短码“,你会有一些想法。有一个组件看起来真的很好,但已经3年没有更新了:
https://github.com/patrickbrouwers/Laravel-Shortcodes
这将是一个很好的起点。我甚至鼓励您派生组件,将其更新到Laravel 5并创建一个拉取请求,而不是创建一个孔新脚本。
以表格为例,您可以像这样扩展:
Shortcode::register('table', function($shortcode, $content, $compiler, $name) {
$items = DB::table($shortcode->table)->get();
$table = '<table class="table-'. $shortcode->table. '">';
foreach ($items as $item) {
// @todo prepare all inner table here
$table .= '<tr><td>...</td></tr>';
}
$table = '</table>';
});并将其用作Shortcode::compile('<h1>Users:</h1> [table table="users"]');
https://stackoverflow.com/questions/46331718
复制相似问题