定制 dnabeast/tusk 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dnabeast/tusk

Composer 安装命令:

composer require dnabeast/tusk

包简介

Creates a plugin file to replace text in a string with any php or html code

README 文档

README

Problem

Your user needs to inject a chunk of code into a basic string using their CMS functionality. You want them to be able to set a Google map or text from a database but you don't want them to be able to run code.

Solution

Set up their code and allow them to reference it in their text string.

Installing

Add the dependency to your project:

composer require DNABeast/tusk

Laravel 5.2:

After updating composer, add the ServiceProvider to the providers array in config/app.php

DNABeast\Tusk\TuskServiceProvider::class,

Add the directory Plugin/lib to your App directory to contain your plugin files.

You may need to clear the view cache

php artisan view:clear

Usage

In your blade file put your string inside the tusk directive.

@tusk('Your string [[- map -]]. Rest of String')

This writes a file in App\Plugins called map.php. If this file already exists nothing happens.

If your map.php file was this

<?php echo '<iframe>Map</iframe>'; ?>

The blade file would replace [[- map -]] and output

Your string <iframe>Map</iframe>. Rest of String

Use Case

  1. Your user can update their contact page with basic text but you don't want to allow iframes. You can still allow them to enter [[- googlemap -]] to inject the google map html required to embed a map.

  2. You have code that can spit out a list of links from the database. You also have basic pages on the site that allow the user to update their content and they can include the list code without having access to the actual code by simply entering [[- linklist -]].

Potential pitfall

You plugin file can be all html but if it has php you need to echo the result. If you return it nothing will display. ie.

<?php
	$x = 34+65;
	return $x; // <- This wont work. You must echo it.
?>

统计信息

  • 总下载量: 53
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-06-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固