home page Site building tutorial Zblog website establishment text

How zblogPHP gets all categories

When writing the configuration of the development theme, it is often used to select the classification to be called by the current module. For example, we can specify the corresponding classification ID for a module on the home page. Usually, we need to find the corresponding classification ID number in the classification management, which will cause inconvenience and affect efficiency. It would be much more convenient if all the classifications were obtained by code and provided to users to directly select operations. It is intuitive and can greatly prompt the operation efficiency. So how does zblogPHP get all categories? Specific implementation code

Under development theme When writing the configuration, it is often used to select the classification to be called by the current module. For example, we can specify the corresponding classification ID for a module on the home page. Usually, we need to find the corresponding classification ID number in the classification management, which will cause inconvenience and affect efficiency.

It would be much more convenient if all the classifications were obtained by code and provided to users to directly select operations. It is intuitive and can greatly prompt the operation efficiency. that zblogphp How do I get all the classifications? The specific implementation code is as follows:

Method 1, get all the classifications, and the subcategories are marked with L

 < select  class="select" name="Forum[umData]">  <? php echo OutputOptionIt em sOfCategories($zbp->Config('umTheme')->umData);  ?> </select>

among $zbp->Config('umTheme')->umData To configure the interface label, the final output code format is as follows:

 <select class="select" name="Forum[umData]"> <option selected="selected" value="1">Product Center</option>    <option value="2">&nbsp; L Jade carving ornaments</option>    <option value="3">&nbsp; L Jade pendant</option>    <option value="4">&nbsp; L Jade bracelet</option> <option value="5">Master craftsman</option> <option value="6">Latest information</option>    <option value="7">&nbsp; L Industry information</option> </select>

Method 2, obtain all classification and classification id numbers, and the sub classification is marked with L

 <? php foreach ($zbp->categorysbyorder as $cate){ ?>    <option value="<?php echo $cate->ID;  ?> " >        <? php if ($cate->Level == 1||$cate->Level == 2) {echo'└';} echo $cate->Name;?>< span>(<? php echo $cate->ID;  ?>)</ span>    </option>  <? php } ?>

The final output code format is as follows:

 <option selected="selected" value="1">Product Center<span>(1)</span></option> <option value="2">L Jade Carving Ornaments<span>(2)</span></option> <option value="3">L Jade pendant<span>(3)</span></option> <option value="4">L Jade bracelet<span>(4)</span></option> <option value="5">Master craftsman<span>(5)</span></option> <option value="6">Latest information<span>(6)</span></option> <option value="7">L Industry information<span>(6)</span></option>


Reward
poster

This article is written by Beautiful theme Original or collected and released

Please indicate the address of this article for reprinting: https://www.umtheme.com/zblog/149.html

Related recommendations

 The list of zblog custom categories is sorted by browsing volume, comments, update time, ID or author

The list of zblog custom categories is sorted by browsing volume, comments, update time, ID or author

ZBLOG provides rich interfaces to facilitate the personalized customization of webmasters, so it is easy to reorder articles. For example, it may be necessary to adjust the default sorting of the system during the development and production process (the latest one is first), so that the list of articles under a certain category on its website is based on the specified (browse volume
Zblog website establishment 2022.10.16 zero three thousand two hundred and eighty-four
Post comments

Thank you for your support