Home > Article > Backend Development > Practical tips for hiding columns in dedecms
In the process of using dedeCMS to build a website, sometimes we need to hide some columns and prevent them from being displayed in the front desk. This can effectively manage website columns and keep the overall structure of the website clear. The following will introduce some practical techniques for hiding columns in dedeCMS, with specific code examples.
Open the template directory of dedeCMS and find the template file to be modified, usually "list.htm" or "article_list.htm".
Add the following code at the corresponding location:
<?php // 获取栏目ID为1的栏目信息 $channel = new ChannelModel(1); $sonids = $channel->SonIds(); $where = isset($sonids) ? "`classid` NOT IN ({$sonids})" : ''; $where .= " AND ..."; // 可以添加其他条件 ?>
In the above code, we first instantiate the ChannelModel class and pass in the ID of the column that needs to be hidden. Then use the SonIds method to obtain all sub-column IDs under this column and exclude them. You can then add other conditions as needed to further filter the columns that need to be hidden.
<script type="text/javascript"> $(document).ready(function(){ $('.hidden-column').hide(); }); </script>
In the above code, we use the jQuery selector to find the element with class "hidden-column" and hide it . You can modify the selector conditions according to actual needs to hide different columns.
Through the above methods, we can easily hide the required columns in dedeCMS and keep the website clean and orderly. Of course, remember to back up website data and files before operation to avoid unnecessary losses. I hope the above content will be helpful to you, and I wish you good luck in building your dedeCMS website!
The above is the detailed content of Practical tips for hiding columns in dedecms. For more information, please follow other related articles on the PHP Chinese website!