leon Publish time 2013-10-31 07:18

How to write a single page with discuz?

本帖最后由 leon 于 2013-10-31 08:26 编辑

Some times, we need to write "stand alone" pages. I mean, write the page's content completely by yourself. But, of course, you won't like to write all the html codes.

Here are some ways to show you how to write a single page.

Method 1(Easiest):

1. Write or copy a single page's template file, put it in your folder "//portal/portal_topic_.htm", and you can give it a name to display in your discuz console by code "<!--your diy template-->".<!--{subtemplate common/header}-->   
<!--ifpay diy template-->
<style id="diy_style" type="text/css"></style>
<div id="pt" class="bm cl">
    <div class="z">
      <a href="./" class="nvhm" title="{lang homepage}">$_G</a><em>»</em>
      <a href="forum.php">$_G</a><em>»</em>
      <a href="javascript:;">$navtitle</a>
    </div>
</div>
<div class="wp">
<!----><div id="diy1" class="area"></div><!---->
</div>
<div id="ct" class="wp cl ct2">
    <div class="mn bm cl" style="float:left;">
      <div class="bm_h">
          <div align="right">What do you want to show here?<A title="" href="http://www.xxx.com/thread-15109-1-1.html" target=_blank><FONT color=#1a6be6>Click to submit</FONT></A></div>
      </div>
   <div class="bm_c">
            <!----><div id="diy5" class="area"></div><!---->
      </div>
      
    </div>
   
      <div class="sd" style="float:right;">
   
      <div class="bm">
            <div class="bm_h">
               <h2>Menu1</h2>
            </div>
            <div class="bm_c">
               <p class="xl xl2 cl" style="line-height:25px;">
                      <!----><div id="diy2" class="area"></div><!---->
               </p>
            </div>
      </div>
      
      <div class="bm">
            <div class="bm_h">
               <h2>Menu2</h2>
            </div>
            <div class="bm_c">
               <!----><div id="diy3" class="area"></div><!---->
            </div>
      </div>

      
      <div class="bm">
         <div class="bm_h">
            <h2>Menu13</h2>
         </div>
         <div class="bm_c" >
                <!----><div id="diy4" class="area"></div><!---->
         </div>
      </div>      
    </div>   
</div>
<div class="wp">
<!----><div id="diy6" class="area"></div><!---->
</div>

<!--{subtemplate common/footer}-->2. Create a topic by discuz admin console.




3. Done.


Method 2(If you don't want to manage the single page by discuz topic):
1. Repeat method 1's step 1.
2. Add a php file in your discuz's home folder. for example: http://localhost/discuz/xxx.php
3. Write codes.<?php
define('APPTYPEID', 0); //Module ID, not repeat with other
define('CURSCRIPT', 'ifpay');//Body's Class
require './source/class/class_core.php';//Import discuz system
$discuz = & discuz_core::instance();// initial it
$discuz->init();

loadcache('diytemplatename');//If your need DIY, you need to add this.

$navtitle = 'SDK FAQ'; //'Single page's title';
$metakeywords = 'Android SDK, Mobile Payment, SMS Shortcode'; //'keywords1,ketwords2';
$metadescription = 'ifpay android SMS shortcode sdk for mobile payment'; //'description';

include template('diy:portal/portal_topic_diy');//import your template file
?>4. Done.

Why we need to add a single page like this?
1 reason is that you can write any content in this page, and make its content language switch with your language pack.


leon Publish time 2013-10-31 07:28

About Method 2, now I don't find a perfect solution to put the .php file from discuz root-folder into sub-folder. Maybe someone can provide a suggestion?

kaaleth Publish time 2013-10-31 08:53

Try this solution :)
http://codersclub.org/discuzx/forum.php?mod=viewthread&tid=2702&fromuid=1851

leon Publish time 2013-11-02 13:47

static/image/common/user_online.gif kaaleth static/image/common/clock.gif 2013-10-31 09:53
Try this solution
http://codersclub.org/discuzx/forum.php?mod=viewthread&tid=2702&fromuid=1851

...
$discuz->init();
/*vot*/      settings_localize(); // Localize Navigation & Settings
...I add it to my single file "faq.php", but seems like it is not for my question.
When I try to put it to sub-folder, an issue happened, and It make the URL of CSS&Javascript error.




Pages: [1]
View full version: How to write a single page with discuz?