How to change dz portal related reading to automatically add articles

For related reading, you need to manually select each time you publish an article. If the collection is very troublesome, you can let it randomly call the following 10 articles in this category, so you don't need to manually select each time.
Modify the method to find the \source\module\portal\portal_view.php file to
find the code

q u e r y = D B : : q u e r y ( " S E L E C T a . a i d , a . t i t l e F R O M " . D B : : t a b l e ( ′ p o r t a l a r t i c l e r e l a t e d ′ ) . " r L E F T J O I N " . D B : : t a b l e ( ′ p o r t a l a r t i c l e t i t l e ′ ) . " a O N a . a i d = r . r a i d W H E R E r . a i d = ′ query = DB::query("SELECT a.aid,a.title FROM ".DB::table('portal_article_related')." r LEFT JOIN ".DB::table('portal_article_title')." a ON a.aid=r.raid WHERE r.aid=' query=DB::query("SELECTa.aid,a.titleFROM".DB::table(portalarticlerelated)."rLEFTJOIN".DB::table(portalarticletitle)."aONa.aid=r.raidWHEREr.aid= Aid' ORDER BY r.displayorder");
modify it to

q u e r y = D B : : q u e r y ( " S E L E C T a i d , t i t l e F R O M " . D B : : t a b l e ( ′ p o r t a l a r t i c l e t i t l e ′ ) . " w h e r e c a t i d = ′ query = DB::query("SELECT aid,title FROM ".DB::table('portal_article_title')." where catid=' query=DB::query("SELECTaid,titleFROM".DB::table(portalarticletitle)."wherecatid=' Article[catid]' order by rand() limit 10"); That's
it, so when you open the article page, the bottom related reading will randomly display 10 articles of this type. It is displayed randomly and will change every time. Related reading You can increase the internal chain, which is good for inclusion and SEO.

================================================= =================
Modify the method to find the \source\module\portal\portal_view.php file to
find the code

q u e r y = D B : : q u e r y ( " S E L E C T a . a i d , a . t i t l e F R O M " . D B : : t a b l e ( ′ p o r t a l a r t i c l e r e l a t e d ′ ) . " r L E F T J O I N " . D B : : t a b l e ( ′ p o r t a l a r t i c l e t i t l e ′ ) . " a O N a . a i d = r . r a i d W H E R E r . a i d = ′ query = DB::query("SELECT a.aid,a.title FROM ".DB::table('portal_article_related')." r LEFT JOIN ".DB::table('portal_article_title')." a ON a.aid=r.raid WHERE r.aid=' query=DB::query("SELECTa.aid,a.titleFROM".DB::table(portalarticlerelated)."rLEFTJOIN".DB::table(portalarticletitle)."aONa.aid=r.raidWHEREr.aid=aid’ ORDER BY r.displayorder");

Add the following code to the above code

/新增随机内容/
$article[‘randomrelated’] = array();
q u e r y = D B : : q u e r y ( " S E L E C T a i d , t i t l e F R O M " . D B : : t a b l e ( ′ p o r t a l a r t i c l e t i t l e ′ ) . " w h e r e c a t i d = ′ query = DB::query("SELECT aid,title FROM ".DB::table('portal_article_title')." where catid=' query=DB::query("SELECTaid,titleFROM".DB::table(portalarticletitle)."wherecatid=article[catid]’ order by rand() limit 12");
while ( v a l u e = D B : : f e t c h ( value = DB::fetch( value=DB::fetch(query)) {
$article[‘randomrelated’][] = $value;
}

/新增相关内容/
$article[‘relatedcontent’] = array();
q u e r y = D B : : q u e r y ( " S E L E C T a . a i d , a . t i t l e F R O M " . D B : : t a b l e ( ′ p o r t a l a r t i c l e r e l a t e d ′ ) . " r L E F T J O I N " . D B : : t a b l e ( ′ p o r t a l a r t i c l e t i t l e ′ ) . " a O N a . a i d = r . r a i d w h e r e c a t i d = ′ query = DB::query("SELECT a.aid,a.title FROM ".DB::table('portal_article_related')." r LEFT JOIN ".DB::table('portal_article_title')." a ON a.aid=r.raid where catid=' query=DB::query("SELECTa.aid,a.titleFROM".DB::table(portalarticlerelated)."rLEFTJOIN".DB::table(portalarticletitle)."aONa.aid=r.raidwherecatid=article[catid]’ order by rand() limit 12");
while ( v a l u e = D B : : f e t c h ( value = DB::fetch( value=DB::fetch(query)) {
$article[‘relatedcontent’][] = $value;
}

The template modification method find the \template\default\portal\view.htm file and
add the following code in the relevant position

/ Add related content /code

            <div id="related_article" class="bm">
                    <div class="bm_h cl">
                            <h3>{lang view_related}</h3>
                    </div>
                    <div class="bm_c">
                            <ul class="xl xl2 cl">
                            <!--{loop $article['relatedcontent'] $value}-->
                                    <li>&bull; <a href="portal.php?mod=view&aid=$value[aid]">$value[title]</a></li>
                            <!--{/loop}-->
                            </ul>
                    </div>
            </div>
            <!--{/if}-->

----/ Add random content /-------Code

    <!--{if $article['randomrelated']}-->
            <div id="related_article" class="bm">
                    <div class="bm_h cl">
                            <h3>最新动态</h3>
                    </div>
                    <div class="bm_c">
                            <ul class="xl xl2 cl">
                            <!--{loop $article['randomrelated'] $value}-->
                                    <li>&bull; <a href="portal.php?mod=view&aid=$value[aid]">$value[title]</a></li>
                            <!--{/loop}-->
                            </ul>
                    </div>
            </div>
            <!--{/if}-->

Guess you like

Origin blog.csdn.net/dafanpai/article/details/100013347