In previous versions of 7.2, I wrote a single page creation tutorial, which could be divided into a sidebar or a sidebar. Many webmasters also learned how to create their own pages based on the tutorial. In fact, the single-page production of Version X is the same as that of version 7.2. As long as you study it carefully, you will find that there are only a few lines in PHP. Code Slightly different. First, the single page includes the PHP file of the single page and the template (.htm) file of the single page, such as: host.php?host.htm Hidden content of this post The content of the single-page PHP file is as follows:
- <? PHP
- Require './source/class/class_core.php'; // introduce the system core file
- $ Discuz = & discuz_core: instance (); // The following Code creates and initializes an object.
- $ Discuz-> cachelist = $ cachelist;
- $ Discuz-> Init ();
- Include template ('Forum/host'); // call the single-page template file
- ?>
Copy code In this example, hostname is the template file name without adding the .htm extension. The template file is stored in the Forum directory under the current style directory; The single-page PHP file is stored in the Forum root directory; After creating the PHP file, create the template file. The basic code is as follows:
- {Subtemplate common/header}
- <Div id = "PT" class = "WP">
- <A href = "index. php" class = "nvhm"> $ _ g [setting] [bbname] </a> & rsaquo; Dynamic DRC posts
- </Div>
- <Style id = "diy_style" type = "text/CSS"> </style>
- <Div id = "CT" class = "WP Cl W">
- <Div class = "Mn MW">
- <Div class = "content">
- Here is the code of the text area.
- </Div>
- </Div>
- </Div>
- {Subtemplate common/footer}
Copy code Where:
- <A href = "index. php" class = "nvhm"> $ _ g [setting] [bbname] </a> & rsaquo; Dynamic DRC posts
Copy code This line shows the path on a single page, for example, discuz! Rescue centre? DRC posts are dynamic. {subtemplate common/header} and {subtemplate common/footer} are call page headers and footer templates respectively, so that the single page style is consistent with that of the Forum; So far, the basic single page has been created. See the demonstration effect: http://bbs.7drc.com/host.php ----------------------------------- The following is a single page template with the right sidebar ----------------------------------------- The template file code above does not contain a sidebar. The code of the single-page template file with a sidebar is as follows:
-
- {Subtemplate common/header}
-
- <Div id = "PT" class = "WP"> <a href = "index. PHP "class =" nvhm ">$ _ g [setting] [bbname] </a> & rsaquo; member style </div>
-
- <Div id = "CT" class = "WP Cl N">
-
- <Div class = "MN">
-
- <Div class = "BM">
-
- <H1 class = "MT"> classified browsing
-
- <Div class = "datalist" style = "margin: 10px 0;">
-
-
- Here is the body area code
-
- </Div>
-
- </Div>
-
- </Div>
-
-
- <! -- The code in the sidebar starts -->
-
- <Div id = "PSD" class = "SD">
-
-
- <Div class = "bn">
-
- <P> <strong> topic name </P>
-
- <P> <a href = "#"> sidebar menu name </a> </P>
-
- <P> <a href = "#"> sidebar menu name </a> </P>
-
- <P> <a href = "#"> sidebar menu name </a> </P>
-
- </Div>
-
-
- <Div class = "bn">
-
- <P> <strong> Management Panel </strong> </P>
-
- <P> <a href = "#"> Add a Category </a> </P>
-
- <P> <a href = "#"> Manage a Category </a> </P>
- <P> <a href = "#"> return to membership </a> </P>
-
- </Div>
-
-
- <Div class = "bn" style = "border-bottom: none;">
-
- <P> <strong> copyright information </strong> </P>
-
- <P> prepared by: Unfinished </P>
-
- <P> copyright: DRC </P>
-
- <P> Website: bbs.7drc.com </P>
-
- </Div>
-
-
- </Div>
-
- <! -- The code of the sidebar area ends -->
-
- </Div>
-
-
- {Subtemplate common/footer}
Copy code In the code of the sidebar area, each <Div class = "bn"> block is a sidebar menu area; Demonstration effect see: http://bbs.7drc.com/plugin.php? Id = drc_shownow: Main ------------------------- The following shows the right-side Navigation Pane and the multi-page tab switch -------------------------------- I just saw a Webmaster on the forum asking how to switch the multi-page tab on a single page. The following describes how to switch the tabs; In fact, there are a few more lines of code, which are included in the DX system and can be used directly. The template code on the right bar is shown in the following figure:
- <H1 class = "MT"> classified browsing
Copy code Add the following to this line:
- <Ul class = "TB Cl">
- <LI <! -- {If empty ($ _ g [gp_viewtype]) | $ _ g [gp_viewtype] = 'new'} --> class = "A" <! -- {/If} --> <a href = "host. php? Viewtype = new "> latest release </a> </LI>
- <LI <! -- {If $ _ g [gp_viewtype] = 'view'} --> class = "A" <! -- {/If} --> <a href = "host. php? Viewtype = view "> browsing ranking </a> </LI>
- <LI <! -- {If $ _ g [gp_viewtype] = 'comment'} --> class = "A" <! -- {/If} --> <a href = "host. php? Viewtype = comment "> reply ranking </a> </LI>
- <LI <! -- {If $ _ g [gp_viewtype] = 'rate'} --> class = "A" <! -- {/If} --> <a href = "host. php? Viewtype = Rate "> ranking </a> </LI>
- </Ul>
Copy code Explain the code above. Each <li> label is a tab, with the hyperlink host. php? Viewtype = new. viewtype specifies a variable and the value is new. When you click this tab, $ _ g [gp_viewtype] will get this value, then, you can determine the value of $ _ g [gp_viewtype] to select whether the current tab is the focus option. Since there are multiple pages, there are two ways to do this: one is to create multiple single pages, including multiple PHP files and multiple template files. Of course, this method is direct, but it is troublesome. You can determine the value of $ _ g [gp_viewtype] In the same template file to display different content. For example, in the body area, the following code is shown:
- <! -- {If $ _ g [gp_viewtype] = 'new'} -->
- The content under the new tab is displayed.
- <! -- {Elseif $ _ g [gp_viewtype] = 'view'} -->
- The content under the view tab is displayed.
- <! -- {Elseif $ _ g [gp_viewtype] = 'comment'} -->
- The content under the comment tab is displayed.
- <! -- {/If} -->
Copy code This achieves the effect of multiple pages in a template file. Click different tabs to display different content. ---------------------------- The following is a DIY single-page tutorial -------------------------------- How can I use the DIY function of DX in my own single page? You only need to perform a slight transformation, as shown below: Change the line of code of the single-page PHP file calling template:
- Include template ('diy: Forum/host ');
Copy code In this way, you can load the DIY module and add the DIY area to the single-page template, as shown below:
- <! -- [DIY = diy1] --> <Div id = "diy1" class = "area"> </div> <! -- [/DIY] -->
Copy code This is a DIY region. If you want to have multiple regions, then:
- <! -- [DIY = diy1] --> <Div id = "diy1" class = "area"> </div> <! -- [/DIY] -->
- <! -- [DIY = diy2] --> <Div id = "diy2" class = "area"> </div> <! -- [/DIY] -->
- <! -- [DIY = diy3] --> <Div id = "diy3" class = "area"> </div> <! -- [/DIY] -->
Copy code Separate diy1, diy2, and diy3. For example, add <Div id = "PT" class = "WP"> above or below the single-page template code:
- <Div class = "WP">
- <! -- [DIY = diy1] --> <Div id = "diy1" class = "area"> </div> <! -- [/DIY] -->
- </Div>
Copy code In this way, you can implement the single-page DIY function. It should be noted that the DIY area should be added to the template. According to your own needs, it is not fixed. Where should I design it, where to join. So far, this tutorial is over. I hope the Webmasters can carefully read and think and study it, and create their own single pages. |