本文作者:心月

phpcmsv9移动端页面静态化实现方法——模板修改

心月IT博客 05-09
phpcmsv9移动端页面静态化实现方法——模板修改摘要:移动端url规则 栏目页url规则:m {$catdir} index html|m {$catdir} p{$page} html示例:m news p2 html 内容页url规则:m {$catdir} {$id} html|m {$catdir} {$id}_{$page} html示例:m news 1_2 html 移动端url规则的目的是让所有的移动端页面都生成在 m 文件夹下。

1、添加静态页规则

pc端url规则
栏目页url规则:{$catdir}/index.html|{$catdir}/p{$page}.html示例:news/p2.html
内容页url规则:{$catdir}/{$id}.html|{$catdir}/{$id}_{$page}.html示例:news/1_2.html
移动端url规则
栏目页url规则:m/{$catdir}/index.html|m/{$catdir}/p{$page}.html示例:m/news/p2.html
内容页url规则:m/{$catdir}/{$id}.html|m/{$catdir}/{$id}_{$page}.html示例:m/news/1_2.html

移动端url规则的目的是让所有的移动端页面都生成在 m 文件夹下。


2、模板修改

在添加栏目和栏目修改的编辑页面中添加移动端栏目页url规则和移动端内容页url规则

①栏目模板修改

    a.添加栏目模板

模板文件位置:phpcms/modules/admin/templates/category_add.tpl.php 

大约在 163 行左右

需要添加的内容为<!--m start--> <!--m end--> 之间的代码内容。

   <tr>
      <th><?php echo L('show_urlrules');?>:</th>
      <td><div id="show_php_ruleid" style="display:<?php if($setting['content_ishtml']) echo 'none';?>">
	  <?php
		echo form::urlrule('content','show',0,$setting['category_ruleid'],'name="show_php_ruleid"');
	?>
	</div>
	<div id="show_html_ruleid" style="display:<?php if(!$setting['content_ishtml']) echo 'none';?>">
	  <?php	
		echo form::urlrule('content','show',1,$setting['category_ruleid'],'name="show_html_ruleid"');
	?>
	</div>
	</td>
    </tr>
<!--m start-->
    <tr>
      <th width="200"><?php echo L('m_html_category');?>:</th>
      <td>
	  <input type='radio' name='setting[m_ishtml]' value='1' <?php if($setting['m_ishtml']) echo 'checked';?> onClick="$('#m_category_php_ruleid').css('display','none');$('#m_category_html_ruleid').css('display','');"> <?php echo L('yes');?>&nbsp;&nbsp;&nbsp;&nbsp;
	  <input type='radio' name='setting[m_ishtml]' value='0' <?php if(!$setting['m_ishtml']) echo 'checked';?>  onClick="$('#m_category_php_ruleid').css('display','');$('#m_category_html_ruleid').css('display','none');"> <?php echo L('no');?>
	  </td>
    </tr>
	<tr>
      <th><?php echo L('m_html_show');?>:</th>
      <td>
	  <input type='radio' name='setting[m_content_ishtml]' value='1' <?php if($setting['m_content_ishtml']) echo 'checked';?> onClick="$('#m_show_php_ruleid').css('display','none');$('#m_show_html_ruleid').css('display','')"> <?php echo L('yes');?>&nbsp;&nbsp;&nbsp;&nbsp;
	  <input type='radio' name='setting[m_content_ishtml]' value='0' <?php if(!$setting['m_content_ishtml']) echo 'checked';?>  onClick="$('#m_show_php_ruleid').css('display','');$('#m_show_html_ruleid').css('display','none')"> <?php echo L('no');?>
	  </td>
    </tr>
	<tr>
      <th><?php echo L('m_category_urlrules');?>:</th>
      <td><div id="m_category_php_ruleid" style="display:<?php if($setting['m_ishtml']) echo 'none';?>">
	<?php
		echo form::urlrule('content','category',0,$setting['m_category_ruleid'],'name="m_category_php_ruleid"');
	?>
	</div>
	<div id="m_category_html_ruleid" style="display:<?php if(!$setting['m_ishtml']) echo 'none';?>">
	<?php
		echo form::urlrule('content','category',1,$setting['m_category_ruleid'],'name="m_category_html_ruleid"');
	?>
	</div>
	</td>
    </tr>
	
	<tr>
      <th><?php echo L('m_show_urlrules');?>:</th>
      <td><div id="m_show_php_ruleid" style="display:<?php if($setting['m_content_ishtml']) echo 'none';?>">
	  <?php
		echo form::urlrule('content','show',0,$setting['m_category_ruleid'],'name="m_show_php_ruleid"');
	?>
	</div>
	<div id="m_show_html_ruleid" style="display:<?php if(!$setting['m_content_ishtml']) echo 'none';?>">
	  <?php	
		echo form::urlrule('content','show',1,$setting['m_category_ruleid'],'name="m_show_html_ruleid"');
	?>
	</div>
	</td>
    </tr>
    <!--m end-->

    b.修改栏目模板

模板文件位置:phpcms/modules/admin/templates/category_edit.tpl.php

大概在153行左右

需要添加的内容同样为<!--m start--> <!--m end--> 之间的代码内容。

    <tr>
      <th><?php echo L('show_urlrules');?>:</th>
      <td><div id="show_php_ruleid" style="display:<?php if($setting['content_ishtml']) echo 'none';?>">
	  <?php
		echo form::urlrule('content','show',0,$setting['show_ruleid'],'name="show_php_ruleid"');
	?>
	</div>
	<div id="show_html_ruleid" style="display:<?php if(!$setting['content_ishtml']) echo 'none';?>">
	  <?php	
		echo form::urlrule('content','show',1,$setting['show_ruleid'],'name="show_html_ruleid"');
	?>
	</div>
	</td>
    </tr>
<!--m start-->
    <tr>
      <th width="200"><?php echo L('m_html_category');?>:</th>
      <td>
	  <input type='radio' name='setting[m_ishtml]' value='1' <?php if($setting['m_ishtml']) echo 'checked';?> onClick="$('#m_category_php_ruleid').css('display','none');$('#m_category_html_ruleid').css('display','');"> <?php echo L('yes');?>&nbsp;&nbsp;&nbsp;&nbsp;
	  <input type='radio' name='setting[m_ishtml]' value='0' <?php if(!$setting['m_ishtml']) echo 'checked';?>  onClick="$('#m_category_php_ruleid').css('display','');$('#m_category_html_ruleid').css('display','none');"> <?php echo L('no');?>
	  </td>
    </tr>
	<tr>
      <th><?php echo L('m_html_show');?>:</th>
      <td>
	  <input type='radio' name='setting[m_content_ishtml]' value='1' <?php if($setting['m_content_ishtml']) echo 'checked';?> onClick="$('#m_show_php_ruleid').css('display','none');$('#m_show_html_ruleid').css('display','')"> <?php echo L('yes');?>&nbsp;&nbsp;&nbsp;&nbsp;
	  <input type='radio' name='setting[m_content_ishtml]' value='0' <?php if(!$setting['m_content_ishtml']) echo 'checked';?>  onClick="$('#m_show_php_ruleid').css('display','');$('#m_show_html_ruleid').css('display','none')"> <?php echo L('no');?>
	  </td>
    </tr>
	<tr>
      <th><?php echo L('m_category_urlrules');?>:</th>
      <td><div id="m_category_php_ruleid" style="display:<?php if($setting['m_ishtml']) echo 'none';?>">
	<?php
		echo form::urlrule('content','category',0,$setting['m_category_ruleid'],'name="m_category_php_ruleid"');
	?>
	</div>
	<div id="m_category_html_ruleid" style="display:<?php if(!$setting['m_ishtml']) echo 'none';?>">
	<?php
		echo form::urlrule('content','category',1,$setting['m_category_ruleid'],'name="m_category_html_ruleid"');
	?>
	</div>
	</td>
    </tr>
	
	<tr>
      <th><?php echo L('m_show_urlrules');?>:</th>
      <td><div id="m_show_php_ruleid" style="display:<?php if($setting['m_content_ishtml']) echo 'none';?>">
	  <?php
		echo form::urlrule('content','show',0,$setting['m_show_ruleid'],'name="m_show_php_ruleid"');
	?>
	</div>
	<div id="m_show_html_ruleid" style="display:<?php if(!$setting['m_content_ishtml']) echo 'none';?>">
	  <?php	
		echo form::urlrule('content','show',1,$setting['m_show_ruleid'],'name="m_show_html_ruleid"');
	?>
	</div>
	</td>
    </tr>
    <!--m end-->

②单页面模板

    a.单页面添加模板

模板文件位置:phpcms/modules/admin/templates/category_page_add.tpl.php

大概在106行左右

需要添加的内容同样为<!--m start--> <!--m end--> 之间的代码内容。

    <tr>
      <th><?php echo L('urlrule_url');?>:</th>
      <td><div id="category_php_ruleid" style="display:<?php if($setting['ishtml']) echo 'none';?>">
	<?php
		echo form::urlrule('content','category',0,$setting['category_ruleid'],'name="category_php_ruleid"');
	?>
	</div>
	<div id="category_html_ruleid" style="display:<?php if(!$setting['ishtml']) echo 'none';?>">
	<?php
		echo form::urlrule('content','category',1,$setting['category_ruleid'],'name="category_html_ruleid"');
	?>
	</div>
	</td>
    </tr>
    <!--m start-->
    <tr>
        <th width="200"><?php echo L('m_html_category');?>:</th>
        <td>
            <input type='radio' name='setting[m_ishtml]' value='1' <?php if($setting['m_ishtml']) echo 'checked';?> onClick="$('#m_category_php_ruleid').css('display','none');$('#m_category_html_ruleid').css('display','')"> <?php echo L('yes');?>&nbsp;&nbsp;&nbsp;&nbsp;
            <input type='radio' name='setting[m_ishtml]' value='0' <?php if(!$setting['m_ishtml']) echo 'checked';?>  onClick="$('#m_category_php_ruleid').css('display','');$('#m_category_html_ruleid').css('display','none')"> <?php echo L('no');?>
        </td>
    </tr>

    <tr>
        <th><?php echo L('m_urlrule_url');?>:</th>
        <td><div id="m_category_php_ruleid" style="display:<?php if($setting['ishtml']) echo 'none';?>">
                <?php
                echo form::urlrule('content','category',0,$setting['m_category_ruleid'],'name="m_category_php_ruleid"');
                ?>
            </div>
            <div id="category_html_ruleid" style="display:<?php if(!$setting['ishtml']) echo 'none';?>">
                <?php
                echo form::urlrule('content','category',1,$setting['m_category_ruleid'],'name="m_category_html_ruleid"');
                ?>
            </div>
        </td>
    </tr>
    <!--m end-->

    b.单页面修改模板

模板文件位置:phpcms/modules/admin/templates/category_page_edit.tpl.php

大概在92行左右

需要添加的内容同样为<!--m start--> <!--m end--> 之间的代码内容。

    <tr>
      <th><?php echo L('urlrule_url');?>:</th>
      <td><div id="category_php_ruleid" style="display:<?php if($setting['ishtml']) echo 'none';?>">
	<?php
		echo form::urlrule('content','category',0,$setting['category_ruleid'],'name="category_php_ruleid"');
	?>
	</div>
	<div id="category_html_ruleid" style="display:<?php if(!$setting['ishtml']) echo 'none';?>">
	<?php
		echo form::urlrule('content','category',1,$setting['category_ruleid'],'name="category_html_ruleid"');
	?>
	</div>
	</td>
    </tr>
    <!--m start-->
    <tr>
        <th width="200"><?php echo L('m_html_category');?>:</th>
        <td>
            <input type='radio' name='setting[m_ishtml]' value='1' <?php if($setting['m_ishtml']) echo 'checked';?> onClick="$('#m_category_php_ruleid').css('display','none');$('#m_category_html_ruleid').css('display','')"> <?php echo L('yes');?>&nbsp;&nbsp;&nbsp;&nbsp;
            <input type='radio' name='setting[m_ishtml]' value='0' <?php if(!$setting['m_ishtml']) echo 'checked';?>  onClick="$('#m_category_php_ruleid').css('display','');$('#m_category_html_ruleid').css('display','none')"> <?php echo L('no');?>
        </td>
    </tr>

    <tr>
        <th><?php echo L('urlrule_url');?>:</th>
        <td><div id="m_category_php_ruleid" style="display:<?php if($setting['m_ishtml']) echo 'none';?>">
                <?php
                echo form::urlrule('content','category',0,$setting['m_category_ruleid'],'name="m_category_php_ruleid"');
                ?>
            </div>
            <div id="m_category_html_ruleid" style="display:<?php if(!$setting['m_ishtml']) echo 'none';?>">
                <?php
                echo form::urlrule('content','category',1,$setting['m_category_ruleid'],'name="m_category_html_ruleid"');
                ?>
            </div>
        </td>
    </tr>
    <!--m end-->


处理好的效果图:(别忘了添加语言包,不然会出现英文)

栏目页添加效果图

栏目页添加效果图


单页面添加效果图

单页面添加效果图


    这一步只是完成模板的操作,接下来要处理model中的相关方法,然后才能实现给栏目同时设置移动端url规则。移动端页面静态化的具体实现方法请参考《phpcmsv9移动端页面静态化实现方法——功能实现

文章版权及转载声明:

本文由 心月IT技术博客 博主整理于 05-09
若转载请注明原文及出处:https://www.xinyueseo.com/cms/266.html

分享到:
赞(
发表评论
快捷输入:

验证码

    评论列表 (有 0 条评论,人围观)参与讨论