thinkphp批改及编写标签库,编辑器的使用
thinkphp修改及编写标签库,编辑器的使用
在view目录下创建Index_aaa.html
<ol class="linenums" style="padding-left: 0px;"><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="dec"><!DOCTYPE html></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="tag"><html></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="tag"><head></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="tag"><meta</span><span class="pln"> </span><span class="atn">charset</span><span class="pun">=</span><span class="atv">"UTF-8"</span><span class="tag">></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="tag"><title></span><span class="pln">select</span><span class="tag"></title></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L5"><code class="language-php"><span class="tag"></head></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L6"><code class="language-php"><span class="tag"><body></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L7"><code class="language-php"><span class="tag"><tagLib</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"html"</span><span class="tag">/></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L8"><code class="language-php"><span class="tag"><html:select</span><span class="pln"> </span><span class="atn">options</span><span class="pun">=</span><span class="atv">"address"</span><span class="pln"> </span><span class="atn">selected</span><span class="pun">=</span><span class="atv">"sh"</span><span class="pln"> </span><span class="atn">values</span><span class="pun">=</span><span class="atv">"address"</span><span class="tag">/></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L9"><code class="language-php"></code></li><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="tag"></body></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="tag"></html></span></code></li></ol>
在IndexController.class.php里面编写函数
<ol class="linenums" style="padding-left: 0px;"><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln"> </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> aaa</span><span class="pun">(){</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln"> $this</span><span class="pun">-></span><span class="pln">assign</span><span class="pun">(</span><span class="str">"address"</span><span class="pun">,[</span><span class="str">"sh"</span><span class="pun">=></span><span class="pln"> </span><span class="str">"上海"</span><span class="pun">,</span><span class="str">"天津"</span><span class="pun">,</span><span class="str">"北京"</span><span class="pun">,</span><span class="str">"郑州"</span><span class="pun">]);</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln"> $this</span><span class="pun">-></span><span class="pln">display</span><span class="pun">();</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="pln"> </span><span class="pun">}</span></code></li></ol>
修改此文件可以编写标签库
把输出的几项全部改为val即可解决values='0'
的问题,让values的值等于option的值
编写新的标签
'ms'=>array('attr'=>'id,name,options,selected','close'=>0)
<html:ms id="aa" name="uu" options="address" selected="北京"/><br>
修改后的代码selected的值可以随便写即可
<ol class="linenums" style="padding-left: 0px;"><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln"> </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> _ms</span><span class="pun">(</span><span class="pln">$tag</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln"> $name </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'name'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln"> $options </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'options'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="pln"> $id </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'id'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="pln"> $selected </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'selected'</span><span class="pun">];</span><span class="pln"> </span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L5"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">=</span><span class="pln"> </span><span class="str">'<select id="'</span><span class="pun">.</span><span class="pln">$id</span><span class="pun">.</span><span class="str">'" name="'</span><span class="pun">.</span><span class="pln">$name</span><span class="pun">.</span><span class="str">'" >'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L6"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">.=</span><span class="str">'<?php foreach($'</span><span class="pun">.</span><span class="pln">$options</span><span class="pun">.</span><span class="str">' as $val) { ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L7"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">.=</span><span class="str">'<?php if("'</span><span class="pun">.</span><span class="pln">$selected</span><span class="pun">.</span><span class="str">'"==$val) { ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L8"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<option selected="selected" value="<?php echo $val ?>"><?php echo $val ?></option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L9"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php } else { ?><option value="<?php echo $val ?>"><?php echo $val ?></option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php } ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php } ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'</select>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> $parseStr</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="pln"> </span><span class="pun">}</span></code></li></ol>
可以根据分配的值来确定selected
<ol class="linenums" style="padding-left: 0px;"><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln"> </span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln"> </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> _ms</span><span class="pun">(</span><span class="pln">$tag</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln"> $name </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'name'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="pln"> $options </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'options'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="pln"> $id </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'id'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L5"><code class="language-php"><span class="pln"> $selected </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'selected'</span><span class="pun">];</span><span class="pln"> </span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L6"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">=</span><span class="pln"> </span><span class="str">'<select id="'</span><span class="pun">.</span><span class="pln">$id</span><span class="pun">.</span><span class="str">'" name="'</span><span class="pun">.</span><span class="pln">$name</span><span class="pun">.</span><span class="str">'" >'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L7"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">.=</span><span class="str">'<?php foreach($'</span><span class="pun">.</span><span class="pln">$options</span><span class="pun">.</span><span class="str">' as $val) { ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L8"><code class="language-php"><span class="pln"> </span><span class="com">/* $parseStr .='<?php if("'.$selected.'"==$val) { ?>';*///selected的值可以随便写</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L9"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">.=</span><span class="str">'<?php if($'</span><span class="pun">.</span><span class="pln">$selected</span><span class="pun">.</span><span class="str">'==$val) { ?>'</span><span class="pun">;</span><span class="com">//值可以先分配再写</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<option selected="selected" value="<?php echo $val ?>"><?php echo $val ?></option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php } else { ?><option value="<?php echo $val ?>"><?php echo $val ?></option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php } ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php } ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'</select>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L5"><code class="language-php"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> $parseStr</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L6"><code class="language-php"><span class="pln"> </span><span class="pun">}</span></code></li></ol>
<ol class="linenums" style="padding-left: 0px;"><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln"> </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> aaa</span><span class="pun">(){</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln"> $this</span><span class="pun">-></span><span class="pln">assign</span><span class="pun">(</span><span class="str">"address"</span><span class="pun">,[</span><span class="str">"上海"</span><span class="pun">,</span><span class="str">"天津"</span><span class="pun">,</span><span class="str">"北京"</span><span class="pun">,</span><span class="str">"郑州"</span><span class="pun">]);</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln"> $this</span><span class="pun">-></span><span class="pln">assign</span><span class="pun">(</span><span class="str">"sh"</span><span class="pun">,</span><span class="str">"天津"</span><span class="pun">);</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="pln"> $this</span><span class="pun">-></span><span class="pln">display</span><span class="pun">();</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="pln"> </span><span class="pun">}</span></code></li></ol>
<ol class="linenums" style="padding-left: 0px;"><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="tag"><tagLib</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"html"</span><span class="tag">/></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="tag"><html:ms</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"aa"</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"uu"</span><span class="pln"> </span><span class="atn">options</span><span class="pun">=</span><span class="atv">"address"</span><span class="pln"> </span><span class="atn">selected</span><span class="pun">=</span><span class="atv">"sh"</span><span class="tag">/><br></span></code></li></ol>
用框架本身带的也可以实现
把红线处的$key修改为$val用分配变量的方式也可以实现selected,系统自带的稍加修改,但是值不可以随便写在selected后
<ol class="linenums" style="padding-left: 0px;"><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln"> </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> _select</span><span class="pun">(</span><span class="pln">$tag</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln"> $name </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'name'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln"> $options </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'options'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="pln"> $values </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'values'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="pln"> $output </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'output'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L5"><code class="language-php"><span class="pln"> $multiple </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'multiple'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L6"><code class="language-php"><span class="pln"> $id </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'id'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L7"><code class="language-php"><span class="pln"> $size </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'size'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L8"><code class="language-php"><span class="pln"> $first </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'first'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L9"><code class="language-php"><span class="pln"> $selected </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'selected'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln"> $style </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'style'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln"> $ondblclick </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'dblclick'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln"> $onchange </span><span class="pun">=</span><span class="pln"> $tag</span><span class="pun">[</span><span class="str">'change'</span><span class="pun">];</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="pln"> </span><span class="kwd">if</span><span class="pun">(!</span><span class="pln">empty</span><span class="pun">(</span><span class="pln">$multiple</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L5"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">=</span><span class="pln"> </span><span class="str">'<select id="'</span><span class="pun">.</span><span class="pln">$id</span><span class="pun">.</span><span class="str">'" name="'</span><span class="pun">.</span><span class="pln">$name</span><span class="pun">.</span><span class="str">'" ondblclick="'</span><span class="pun">.</span><span class="pln">$ondblclick</span><span class="pun">.</span><span class="str">'" onchange="'</span><span class="pun">.</span><span class="pln">$onchange</span><span class="pun">.</span><span class="str">'" multiple="multiple" class="'</span><span class="pun">.</span><span class="pln">$style</span><span class="pun">.</span><span class="str">'" size="'</span><span class="pun">.</span><span class="pln">$size</span><span class="pun">.</span><span class="str">'" >'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L6"><code class="language-php"><span class="pln"> </span><span class="pun">}</span><span class="kwd">else</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L7"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">=</span><span class="pln"> </span><span class="str">'<select id="'</span><span class="pun">.</span><span class="pln">$id</span><span class="pun">.</span><span class="str">'" name="'</span><span class="pun">.</span><span class="pln">$name</span><span class="pun">.</span><span class="str">'" onchange="'</span><span class="pun">.</span><span class="pln">$onchange</span><span class="pun">.</span><span class="str">'" ondblclick="'</span><span class="pun">.</span><span class="pln">$ondblclick</span><span class="pun">.</span><span class="str">'" class="'</span><span class="pun">.</span><span class="pln">$style</span><span class="pun">.</span><span class="str">'" >'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L8"><code class="language-php"><span class="pln"> </span><span class="pun">}</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L9"><code class="language-php"><span class="pln"> </span><span class="kwd">if</span><span class="pun">(!</span><span class="pln">empty</span><span class="pun">(</span><span class="pln">$first</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<option value="" >'</span><span class="pun">.</span><span class="pln">$first</span><span class="pun">.</span><span class="str">'</option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln"> </span><span class="pun">}</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln"> </span><span class="kwd">if</span><span class="pun">(!</span><span class="pln">empty</span><span class="pun">(</span><span class="pln">$options</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php foreach($'</span><span class="pun">.</span><span class="pln">$options</span><span class="pun">.</span><span class="str">' as $key=>$val) { ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="pln"> </span><span class="kwd">if</span><span class="pun">(!</span><span class="pln">empty</span><span class="pun">(</span><span class="pln">$selected</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L5"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php if(!empty($'</span><span class="pun">.</span><span class="pln">$selected</span><span class="pun">.</span><span class="str">') && ($'</span><span class="pun">.</span><span class="pln">$selected</span><span class="pun">.</span><span class="str">' == $val || in_array($key,$'</span><span class="pun">.</span><span class="pln">$selected</span><span class="pun">.</span><span class="str">'))) { ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L6"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<option selected="selected" value="<?php echo $val ?>"><?php echo $val ?></option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L7"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php }else { ?><option value="<?php echo $val ?>"><?php echo $val ?></option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L8"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php } ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L9"><code class="language-php"><span class="pln"> </span><span class="pun">}</span><span class="kwd">else</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<option value="<?php echo $val ?>"><?php echo $val ?></option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln"> </span><span class="pun">}</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php } ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="pln"> </span><span class="pun">}</span><span class="kwd">else</span><span class="pln"> </span><span class="kwd">if</span><span class="pun">(!</span><span class="pln">empty</span><span class="pun">(</span><span class="pln">$values</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php for($i=0;$i<count($'</span><span class="pun">.</span><span class="pln">$values</span><span class="pun">.</span><span class="str">');$i++) { ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L5"><code class="language-php"><span class="pln"> </span><span class="kwd">if</span><span class="pun">(!</span><span class="pln">empty</span><span class="pun">(</span><span class="pln">$selected</span><span class="pun">))</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L6"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php if(isset($'</span><span class="pun">.</span><span class="pln">$selected</span><span class="pun">.</span><span class="str">') && ((is_string($'</span><span class="pun">.</span><span class="pln">$selected</span><span class="pun">.</span><span class="str">') && $'</span><span class="pun">.</span><span class="pln">$selected</span><span class="pun">.</span><span class="str">' == $'</span><span class="pun">.</span><span class="pln">$values</span><span class="pun">.</span><span class="str">'[$i]) || (is_array($'</span><span class="pun">.</span><span class="pln">$selected</span><span class="pun">.</span><span class="str">') && in_array($'</span><span class="pun">.</span><span class="pln">$values</span><span class="pun">.</span><span class="str">'[$i],$'</span><span class="pun">.</span><span class="pln">$selected</span><span class="pun">.</span><span class="str">')))) { ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L7"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<option selected="selected" value="<?php echo $'</span><span class="pun">.</span><span class="pln">$values</span><span class="pun">.</span><span class="str">'[$i] ?>"><?php echo $'</span><span class="pun">.</span><span class="pln">$output</span><span class="pun">.</span><span class="str">'[$i] ?></option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L8"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php }else { ?><option value="<?php echo $'</span><span class="pun">.</span><span class="pln">$values</span><span class="pun">.</span><span class="str">'[$i] ?>"><?php echo $'</span><span class="pun">.</span><span class="pln">$output</span><span class="pun">.</span><span class="str">'[$i] ?></option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L9"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php } ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln"> </span><span class="pun">}</span><span class="kwd">else</span><span class="pln"> </span><span class="pun">{</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<option value="<?php echo $'</span><span class="pun">.</span><span class="pln">$values</span><span class="pun">.</span><span class="str">'[$i] ?>"><?php echo $'</span><span class="pun">.</span><span class="pln">$output</span><span class="pun">.</span><span class="str">'[$i] ?></option>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L2"><code class="language-php"><span class="pln"> </span><span class="pun">}</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L3"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'<?php } ?>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L4"><code class="language-php"><span class="pln"> </span><span class="pun">}</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L5"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">.=</span><span class="pln"> </span><span class="str">'</select>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L6"><code class="language-php"><span class="pln"> </span><span class="kwd">return</span><span class="pln"> $parseStr</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L7"><code class="language-php"><span class="pln"> </span><span class="pun">}</span></code></li></ol>
引入ueditor放在js里面修改ueditor.config.js为如下的代码
<ol class="linenums" style="padding-left: 0px;"><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln"> window</span><span class="pun">.</span><span class="pln">UEDITOR_HOME_URL </span><span class="pun">=</span><span class="pln"> </span><span class="str">"/Public/js/ueditor/"</span><span class="pun">;</span><span class="pln"> </span></code></li></ol>
thinkphp里面放百度编辑器
<ol class="linenums" style="padding-left: 0px;"><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="pln"> $parseStr </span><span class="pun">=</span><span class="pln"> </span><span class="str">'<script id="container" name="content" type="text/plain">这里写你的初始化内容</script><script type="text/javascript" src="__ROOT__/Public/js/ueditor/ueditor.config.js"></script><script type="text/javascript" src="__ROOT__/Public/js/ueditor/ueditor.all.js"></script><script type="text/javascript"> var ue = UE.getEditor("container",{emotionLocalization:true,lang:"zh-cn",initialFrameWidth:"80%",initialFrameHeight:320,textarea:"content",initialContent:"欢迎留言!", autoClearinitialContent:true}); </script>'</span><span class="pun">;</span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="pln"> </span></code></li></ol>
然后在Index_aaa.html 里面编写要显示的代码
<ol class="linenums" style="padding-left: 0px;"><li style="list-style-type: none; padding-left: 0px;" class="L0"><code class="language-php"><span class="tag"><tagLib</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"html"</span><span class="tag">/></span></code></li><li style="list-style-type: none; padding-left: 0px;" class="L1"><code class="language-php"><span class="tag"><html:editor</span><span class="pln"> </span><span class="atn">type</span><span class="pun">=</span><span class="atv">"UEDITOR"</span><span class="tag">></html:editor></span></code></li></ol>
来自为知笔记(Wiz)

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Validator can be created by adding the following two lines in the controller.

Working with database in CakePHP is very easy. We will understand the CRUD (Create, Read, Update, Delete) operations in this chapter.
