| |
| | |

CodersClub

 Forgot password?
 Register
Search
View: 6625|Reply: 3
Collapse the left

How to write a single page with discuz?

[Copy link]

 China

Post time: 2013-10-31 07:18
| Show all posts |Read mode
本帖最后由 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 "/[your template]/portal/portal_topic_[xxx].htm", and you can give it a name to display in your discuz console by code "<!--[name]your diy template[/name]-->".
  1. <!--{subtemplate common/header}-->     
  2. <!--[name]ifpay diy template[/name]-->
  3. <style id="diy_style" type="text/css"></style>
  4. <div id="pt" class="bm cl">
  5.     <div class="z">
  6.         <a href="./" class="nvhm" title="{lang homepage}">$_G[setting][bbname]</a><em>»</em>
  7.         <a href="forum.php">$_G[setting][bbname]</a><em>»</em>
  8.         <a href="javascript:;">$navtitle</a>
  9.     </div>
  10. </div>
  11. <div class="wp">
  12. <!--[diy=diy1]--><div id="diy1" class="area"></div><!--[/diy]-->
  13. </div>
  14. <div id="ct" class="wp cl ct2">
  15.     <div class="mn bm cl" style="float:left;">
  16.         <div class="bm_h">
  17.           <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>
  18.         </div>
  19.      <div class="bm_c">
  20.             <!--[diy=diy5]--><div id="diy5" class="area"></div><!--[/diy]-->
  21.         </div>
  22.         
  23.     </div>
  24.    
  25.         <div class="sd" style="float:right;">
  26.    
  27.         <div class="bm">
  28.             <div class="bm_h">
  29.                  <h2>Menu1</h2>
  30.             </div>
  31.             <div class="bm_c">
  32.                  <p class="xl xl2 cl" style="line-height:25px;">
  33.                       <!--[diy=diy2]--><div id="diy2" class="area"></div><!--[/diy]-->
  34.                  </p>
  35.             </div>
  36.         </div>
  37.         
  38.         <div class="bm">
  39.             <div class="bm_h">
  40.                <h2>Menu2</h2>
  41.             </div>
  42.             <div class="bm_c">
  43.                <!--[diy=diy3]--><div id="diy3" class="area"></div><!--[/diy]-->
  44.             </div>
  45.         </div>

  46.         
  47.         <div class="bm">
  48.            <div class="bm_h">
  49.               <h2>Menu13</h2>
  50.            </div>
  51.            <div class="bm_c" >
  52.                 <!--[diy=diy4]--><div id="diy4" class="area"></div><!--[/diy]-->
  53.            </div>
  54.         </div>        
  55.     </div>   
  56. </div>
  57. <div class="wp">
  58. <!--[diy=diy6]--><div id="diy6" class="area"></div><!--[/diy]-->
  59. </div>

  60. <!--{subtemplate common/footer}-->
Copy the Code
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.
  1. <?php
  2. define('APPTYPEID', 0); //Module ID, not repeat with other
  3. define('CURSCRIPT', 'ifpay');//Body's Class
  4. require './source/class/class_core.php';//Import discuz system
  5. $discuz = & discuz_core::instance();// initial it
  6. $discuz->init();

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

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

  11. include template('diy:portal/portal_topic_diy');//import your template file
  12. ?>
Copy the Code
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.


This post contains more resources

You have to Login for download or view attachment(s). No Account? Register

x

 China

 Author| Post time: 2013-10-31 07:28
| Show all posts
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?
Post time: 2013-10-31 08:53
| Show all posts

 China

 Author| Post time: 2013-11-02 13:47
| Show all posts
kaaleth 2013-10-31 09:53
Try this solution
http://codersclub.org/discuzx/forum.php?mod=viewthread&tid=2702&fromuid=1851
  1. ...
  2. $discuz->init();
  3. /*vot*/        settings_localize(); // Localize Navigation & Settings
  4. ...
Copy the Code
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.




This post contains more resources

You have to Login for download or view attachment(s). No Account? Register

x
You have to log in before you can reply Login | Register

Points Rules

Archive|Mobile|Dark room|CodersClub

Top.Mail.Ru
Top.Mail.Ru

2024-05-04 02:38 GMT+3 , Processed in 0.046695 sec., 8 queries .

Powered by Discuz! X3.4 Release 20230520

© 2001-2024 Discuz! Team.

MultiLingual version, Rev. 4301, © codersclub.org

Quick Reply To Top Return to the list