Solution of Phpcms V9 subcat function in sub-station

Source: Internet
Author: User

This is the smile edge of Hefei Information Technology Co., Ltd. in the Web site when encountered a humble but very difficult to solve the problem.


Post the offending code first:

{loop subcat ($catid) $k $v}
    {php $subcatid [] = $k;}
{/loop}
{php $subcatid  = implode (', ', $subcatid);}
<?php
    $sql = "SELECT * from". Gettablepre (). " Enpicture where status=99 and CatID in ($subcatid) Order by ID DESC ";
? >
{pc:get sql= "$sql" page= "$page" return= "Data"}
    {loop $data $r}
        <div class= "CAT_PIC_BD" >
        <a href= "{$r [url]}" ><p class= picborder2 "></p>
        <p>{$r [title]}</p></a>
        </div>
    {/loop}
{/PC}
This piece of code is the function of the current column of all the sub-columns of information and display, but, no matter how the transfer can not be taken out.

Echo var_dump (subcat ($catid)) returns null;

I'll pull a wipe. Depressed, helpless, doubt is not subcat () function parameter pass wrong, then open phpcms/libs/functions/global.func.php find subcat () function, the code is as follows:


/** *
 get sub
 -column * @param $parentid parent ID
 * @param $type column type
 * @param $self contains itself 0 is not included
 * @param $siteid Station  Point ID
/function subcat ($parentid = null, $type = null, $self = ' 0 ', $siteid = ') {
	if (empty ($siteid)) $siteid = Get_siteid ();
	$category = GetCache (' Category_content_ '. $siteid, ' Commons ');
	foreach ($category as $id => $cat) {
		if ($cat [' siteid '] = = $siteid && ($parentid = = NULL | | $cat [' parentid '] = $parentid) && ($type = = NULL | | | $cat [' type '] = = $type)] $subcat [$id] = $cat;
		if ($self = = 1 && $cat [' catid '] = = $parentid &&! $cat [' child '])  $subcat [$id] = $cat;
	}
	return $subcat;
}

Dumbfounded, sure enough, the parameters passed incorrectly. The column type and site ID are not delivered, and after the station cluster function is turned on, the station must pass the $siteid parameter. The modified code is as follows:


{Loop subcat ($catid, 0,0, $siteid) $k $v}
    {php $subcatid [] = $k;}
{/loop}
{php $subcatid  = implode (', ', $subcatid);}
<?php
    $sql = "SELECT * from". Gettablepre (). " Enpicture where status=99 and CatID in ($subcatid) Order by ID DESC ";
? >
{pc:get sql= "$sql" page= "$page" return= "Data"}
    {loop $data $r}
        <div class= "CAT_PIC_BD" >
        <a href= "{$r [url]}" ><p class= picborder2 "></p>
        <p>{$r [title]}</p></a>
        </div>
    {/loop}
{/PC}

Perfect solution to the problem.


Hefei Network Company to find Smile edge information technology, Welcome to exchange.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.