ECSHOP教程之调用分类文章,
ECSHOP教程之调用分类文章,
这几天帮一个朋友弄一个商城,用的是ECSHOP,感觉ECSHOP功能确实够 强大,但是对于不懂程序的人来说,使用起来还是挺复杂,稍微做点修改就得大费周折,如果能像动易那样出一套标签库就好了。
比如深蓝使用的时候需要按分类调用一下文章,这是一个很常见的功能,可以官方并没有提供,只好自己想办法,最后终于找到了办法。请看一下ECSHOP教程
具体实现方法:
举例如首页调用方法:
1、先打开index.php文件找到以下代码:
$smarty->assign(<span>'</span><span>new_articles</span><span>'</span>, index_get_new_articles()); <span>//</span><span> 最新文章</span>
在它下面增加以下:
<span>//</span><span>调用方法</span> <span> $smarty</span>->assign(<span>'</span><span>class_articles_4</span><span>'</span>, index_get_class_articles(<span>4</span>,<span>6</span>)); <span>//</span><span> 分类调用文章 </span><span>//</span><span>调用多个就修改传进去的参数,以及模板接收的变量,其中上面的4就是文章分类ID,其中6是调用数量</span> $smarty->assign(<span>'</span><span>class_articles_5</span><span>'</span>, index_get_class_articles(<span>5</span>,<span>6</span>)); <span>//</span><span> 分类调用文章</span> $smarty->assign(<span>'</span><span>class_articles_6</span><span>'</span>, index_get_class_articles(<span>6</span>,<span>6</span>)); <span>//</span><span> 分类调用文章</span> $smarty->assign(<span>'</span><span>class_articles_7</span><span>'</span>, index_get_class_articles(<span>7</span>,<span>6</span>)); <span>//</span><span> 分类调用文章</span> $smarty->assign(<span>'</span><span>class_articles_8</span><span>'</span>, index_get_class_articles(<span>8</span>,<span>6</span>)); <span>//</span><span> 分类调用文章</span>
<span>//</span><span>在最后?>这个之前增加以下函数</span> <span> function index_get_class_articles($cat_aid, $cat_num) { $sql </span>= <span>"</span><span>SELECT article_id, title,open_type,cat_id,file_url FROM </span><span>"</span> .$GLOBALS[<span>'</span><span>ecs</span><span>'</span>]->table(<span>'</span><span>article</span><span>'</span>). <span>"</span><span> WHERE cat_id = </span><span>"</span>.$cat_aid.<span>"</span><span> and is_open = 1 LIMIT </span><span>"</span><span> . $cat_num; $res </span>= $GLOBALS[<span>'</span><span>db</span><span>'</span>]-><span>getAll($sql); $arr </span>=<span> array(); </span><span>foreach</span> ($res AS $idx =><span> $row) { $arr[$idx][</span><span>'</span><span>id</span><span>'</span>] = $row[<span>'</span><span>article_id</span><span>'</span><span>]; $arr[$idx][</span><span>'</span><span>title</span><span>'</span>] = $row[<span>'</span><span>title</span><span>'</span><span>]; $arr[$idx][</span><span>'</span><span>short_title</span><span>'</span>] = $GLOBALS[<span>'</span><span>_CFG</span><span>'</span>][<span>'</span><span>article_title_length</span><span>'</span>] > <span>0</span> ?<span> sub_str($row[</span><span>'</span><span>title</span><span>'</span>], $GLOBALS[<span>'</span><span>_CFG</span><span>'</span>][<span>'</span><span>article_title_length</span><span>'</span>]) : $row[<span>'</span><span>title</span><span>'</span><span>]; $arr[$idx][</span><span>'</span><span>cat_name</span><span>'</span>] = $row[<span>'</span><span>cat_name</span><span>'</span><span>]; $arr[$idx][</span><span>'</span><span>add_time</span><span>'</span>] = local_date($GLOBALS[<span>'</span><span>_CFG</span><span>'</span>][<span>'</span><span>date_format</span><span>'</span>], $row[<span>'</span><span>add_time</span><span>'</span><span>]); $arr[$idx][</span><span>'</span><span>url</span><span>'</span>] = $row[<span>'</span><span>open_type</span><span>'</span>] != <span>1</span> ?<span> build_uri(</span><span>'</span><span>article</span><span>'</span>, array(<span>'</span><span>aid</span><span>'</span> => $row[<span>'</span><span>article_id</span><span>'</span>]), $row[<span>'</span><span>title</span><span>'</span>]) : trim($row[<span>'</span><span>file_url</span><span>'</span><span>]); $arr[$idx][</span><span>'</span><span>cat_url</span><span>'</span>] = build_uri(<span>'</span><span>article_cat</span><span>'</span>, array(<span>'</span><span>acid</span><span>'</span> => $row[<span>'</span><span>cat_id</span><span>'</span><span>])); } </span><span>return</span><span> $arr; }</span>
2、第二步是在index.dwt模板想调用的地方增加以下代码,(注:以下调上面设置里的分类ID为8的文章列表):
<!--{<span>foreach</span> <span>from</span>=$class_articles_8 item=article}--> <li><a href=<span>"</span><span>{$article.url}</span><span>"</span> title=<span>"</span><span>{$article.title|escape:html}</span><span>"</span>><!--{$article.short_title|truncate:<span>15</span>:<span>true</span>}--></a></li> <!--{/<span>foreach</span>}-->
按以上方法调用成功。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Dewu APP is currently a very popular brand shopping software, but most users do not know how to use the functions in Dewu APP. The most detailed usage tutorial guide is compiled below. Next is the Dewuduo that the editor brings to users. A summary of function usage tutorials. Interested users can come and take a look! Tutorial on how to use Dewu [2024-03-20] How to use Dewu installment purchase [2024-03-20] How to obtain Dewu coupons [2024-03-20] How to find Dewu manual customer service [2024-03-20] How to check the pickup code of Dewu [2024-03-20] Where to find Dewu purchase [2024-03-20] How to open Dewu VIP [2024-03-20] How to apply for return or exchange of Dewu

1. How can you make money by publishing articles on Toutiao today? How to earn more income by publishing articles on Toutiao today! 1. Activate basic rights and interests: original articles can earn profits by advertising, and videos must be original in horizontal screen mode to earn profits. 2. Activate the rights of 100 fans: if the number of fans reaches 100 fans or above, you can get profits from micro headlines, original Q&A creation and Q&A. 3. Insist on original works: Original works include articles, micro headlines, questions, etc., and are required to be more than 300 words. Please note that if illegally plagiarized works are published as original works, credit points will be deducted, and even any profits will be deducted. 4. Verticality: When writing articles in professional fields, you cannot write articles across fields at will. You will not get appropriate recommendations, you will not be able to achieve the professionalism and refinement of your work, and it will be difficult to attract fans and readers. 5. Activity: high activity,

After rain in summer, you can often see a beautiful and magical special weather scene - rainbow. This is also a rare scene that can be encountered in photography, and it is very photogenic. There are several conditions for a rainbow to appear: first, there are enough water droplets in the air, and second, the sun shines at a low angle. Therefore, it is easiest to see a rainbow in the afternoon after the rain has cleared up. However, the formation of a rainbow is greatly affected by weather, light and other conditions, so it generally only lasts for a short period of time, and the best viewing and shooting time is even shorter. So when you encounter a rainbow, how can you properly record it and photograph it with quality? 1. Look for rainbows. In addition to the conditions mentioned above, rainbows usually appear in the direction of sunlight, that is, if the sun shines from west to east, rainbows are more likely to appear in the east.

1. First open WeChat. 2. Click [+] in the upper right corner. 3. Click the QR code to collect payment. 4. Click the three small dots in the upper right corner. 5. Click to close the voice reminder for payment arrival.

PhotoshopCS is the abbreviation of Photoshop Creative Suite. It is a software produced by Adobe and is widely used in graphic design and image processing. As a novice learning PS, let me explain to you today what software photoshopcs5 is and how to use photoshopcs5. 1. What software is photoshop cs5? Adobe Photoshop CS5 Extended is ideal for professionals in film, video and multimedia fields, graphic and web designers who use 3D and animation, and professionals in engineering and scientific fields. Render a 3D image and merge it into a 2D composite image. Edit videos easily

With the continuous development of smart phones, the functions of mobile phones have become more and more powerful, among which the function of taking long pictures has become one of the important functions used by many users in daily life. Long screenshots can help users save a long web page, conversation record or picture at one time for easy viewing and sharing. Among many mobile phone brands, Huawei mobile phones are also one of the brands highly respected by users, and their function of cropping long pictures is also highly praised. This article will introduce you to the correct method of taking long pictures on Huawei mobile phones, as well as some expert tips to help you make better use of Huawei mobile phones.

PHP Tutorial: How to Convert Int Type to String In PHP, converting integer data to string is a common operation. This tutorial will introduce how to use PHP's built-in functions to convert the int type to a string, while providing specific code examples. Use cast: In PHP, you can use cast to convert integer data into a string. This method is very simple. You only need to add (string) before the integer data to convert it into a string. Below is a simple sample code

Honor mobile phones have always been favored by consumers because of their excellent performance and stable system. Recently, Honor mobile phones have released a new Hongmeng system, which has attracted the attention and expectations of many users. Hongmeng system is known as the system that "unifies the world". It has a smoother operating experience and higher security, allowing users to experience a new world of smartphones. Many users have expressed that they want to upgrade their Honor mobile phone system to the Hongmeng system. So, let’s take a look at the upgrade tutorial of the Honor mobile phone’s Hongmeng system. firstly, I
