How do I write the title and content in the content template?

Source: Internet
Author: User
Tags compact shuffle
This is a php file, how can I write the title and content in the content template? Ask the great God to write a template for a single piece of content. Thank you, because the code is too long, I deleted a part, emergency, thank you kindly people

 Spargs (' uid ')) {$uid = (int) $this->spargs (' uid '); $cond = "and B.uid = ' $uid '";} if ($this->spargs (' Pagelimit ')) {$pageLimit = ($this->spargs (' Pagelimit ') <)? $this->spargs ('  Pagelimit '): 30; Custom paging}else{$pageLimit = $this->yb[' show_page_num ');} Left JOIN ' ". Dbpre. " Follow ' as f on (B.uid = f.touid and F.uid = ' $uid ') $sql = "Select B. *, k.id as Likeid, M.username,m.domainfrom '". Dbpre. " Blog ' as B left JOIN '. Dbpre. " Likes ' as K on (b.bid = k.bid and K.uid = ' $this->uid ') left JOIN ' ". Dbpre. " Member ' as M on b.uid = m.uid where B.open = 1 $cond ORDER by b.time desc "; $data [' blog '] = Spclass (' Db_blog ')->sppager ($this->spargs (' page ', 1), $pageLimit)->findsql ($sql); $data [' page '] = Spclass (' Db_blog ')->sppager () Getpager (), unset ($data [' page '] [' all_pages ']), if (!empty ($data [' blog])) {foreach ($data [' Blog '] as & $d) {$this- >foramt_feeds ($d);} $this->api_success ($data);} else{$this->api_success ("");}} Gets a single blog function getoneblog () {$bid = (int) $thIs->spargs (' bid '); $sql = "Select B. *, k.id as Likeid, M.username,m.domainfrom '". Dbpre. " Blog ' as B left JOIN '. Dbpre. " Likes ' as K on (b.bid = k.bid and K.uid = ' $this->uid ') left JOIN ' ". Dbpre. " Member ' as M on b.uid = M.uid where B.open in (1,-2) and b.bid = ' $bid ' "; $data [' blog '] = Spclass (' Db_blog ')->findsql ($ SQL), foreach ($data [' Blog '] as & $d) {$this->foramt_feeds ($d, 0);} $this->api_success ($data);} Get the user I care about feedsfunction followfeeds () {$followuid = Spclass (' Db_follow ')->getfollowuid ($this->uid); if ($ Followuid) {$sql = "Select B. *, k.id as Likeid, M.username,m.domainfrom '". Dbpre. " Blog ' as B left JOIN '. Dbpre. " Likes ' as K on (b.bid = k.bid and K.uid = ' $this->uid ') left JOIN ' ". Dbpre. " Member ' as M on b.uid = m.uid where B.open = 1 ", $sql. =" and B.uid in ($followuid) and b.open=1 ORDER by b.time desc "; $d ata[' blog ' = Spclass (' Db_blog ')->sppager ($this->spargs (' page ', 1),->findsql ($sql); $data [' page '] = Spclass (' Db_blog ')->sppager ()->getPager (); foreach ($data [' Blog '] as & $d) {$this->foramt_feeds ($d);}} $this->api_success ($data);}        /* Get a list of randomly recommended images, home with */function recommendimg () {$type = 3;//Get image $cachename = ' recommend_shuffle_ '. $type; if (!spaccess (' R ', $cachename)) {$recommend = Spclass (' Db_blog ')->recommend_shuffle ($type); foreach ($recommend As $d) {$body = Split_attribute ($d [' body ']), if (Is_array ($body [' attr '] [' img ']) {foreach ($body [' attr '] [' img '] as $IMG) {$imgs [] = array (' bid ' = = $d [' Bid '], ' uid ' + $d [' uid '], ' img ' = ' $img ' [' url '], ' username ' = ' + ' $d [' user '] [' Username '], ' H_url ' =>gouserhome (the ' uid ' = = $d [' user '] [' uid ']), ' h_img ' =>avatar (Array (' uid ' = = $d [' User ' [' uid '], ' size ' = ' small '), ' B_url ' =>gouserblog (' bid ' = ' + ' $d [' bid '], ' domain ' and ' = ' $d [' user '] ['            ' UID ' = $d [' user '] [' uid ']));}}}        Spaccess (' W ', $cachename, $imgs, 86400);        }else{$imgs = spaccess (' R ', $cachename);         } $count = count ($imgs); $numbers = Range (0, $count-1);        Shuffle ($numbers);                 $queue = Array_slice ($numbers, 0, 1);        $result = Array ();        foreach ($queue as $d) {$result = $imgs [$d]; } $this->api_success ($result);} Discovery Channel randomly found the latest 100 blog content, take the first 15 function Discoverblog () {$num = ($this->spargs (' num '))? $this->spargs (' num '): 15;$ page = ($this->spargs (' page ', 0))? $num * ($this->spargs (' page ')-1): 0; $isshuffle = ($this->spargs (' Isshuffle ', 0))? 1:0; $type = ' all '; $cachename = ' Recommend_shuffle_ '. $type, if (!spaccess (' R ', $cachename)) {$recommend = Spclass (' db_ Blog ')->recommend_shuffle ($type, 150);//Number 15*10$data = Array (); foreach ($recommend as $d) {$body = Split_attribute ($ d[' body '); if ($d [' type '] = = 1) {$d [' attr '] = ';} if ($d [' type '] = = 3) {$d [' attr '] = $body [' attr '] [' img '][0][' URL '];} if ($d [' type '] = = 2 | | $d [' type '] = = 4) {if (!empty ($body [' attr '])) {if (Is_array ($body [' attr '])} {if (count ($body [' attr ']) <= 1) {if ($body [' attr '] [' type '] = = ' Yinyuetai ') {//special handling of the music table $d[' attr '] = ' index.phP?c=blog&a=getyytimg&src= '. $body [' attr '] [' img '];}  else{$d [' attr '] = $body [' attr '] [' img ']; Return the picture to the foreground}}else{if ($body [' attr '][0][' type '] = = ' Yinyuetai ') {//special handling to the music station $d[' attr '] = ' index.php?c=blog&a= Getyytimg&src= '. $body [' attr '][0][' img '];}  else{$d [' attr '] = $body [' attr '][0][' img ']; Return the picture to the foreground}}}}else{$d [' attr '] = $body [' attr '];}} if ($d [' attr ']) {$data [] = array (' bid ' = + $d [' Bid '], ' title ' = = $d [' title '], ' body ' =>utf8_substr ($ strip_tags ($ body[' body '), 0,120), ' type ' = = $d [' type '], ' uid ' = ' = ' ' uid ', ' username ' + $d [' user '] [' username '], ' b_url ' = >gouserblog (' bid ' = $d [' Bid '], ' domain ' and ' = ' $d [' user '] [' domain '], ' uid ' + $d [' user '] [' uid ']), ' tag ' = = ($d [' tag ']! = ')? Array_shift ((' Explode (', ', $d [' tag ')]): ', ' img ' = ' + ' $d [' attr '];}} Unset ($recommend); Spaccess (' W ', $cachename, $data, 86400);} else{$data = spaccess (' R ', $cachename);}         $count = count ($data);        $numbers = Range (0, $count-1), if ($isshuffle) {shuffle ($numbers);} $queue = Array_slice ($numbers, $pAge, $num);        $result = Array ();        foreach ($queue as $d) {$result [] = $data [$d]; }unset ($data); $this->api_success ($result);} /* Discovery Channel randomly found 20 tag model has been cached */function Discovertag () {$tags = Spclass (' db_tags ')->discovertag (); $maxhit = 0;foreach ($ tags as & $d) {if ($d [' hit '] > $maxhit) {$maxhit = $d [' hits '];} if (Is_array ($d [' ulist '])) {foreach ($d [' Ulist '] as & $list) {$list [' h_url '] = gouserhome (' uid ' = + $list [' UID '], ' domain ' = $list [' domain ']), $list [' h_img '] = Avatar (' uid ' = ' $list [' uid '], ' size ' = ' small ')}} $data = Array (), $data [' maxhit '] = $maxhit; $data [' data '] = $tags; $this->api_success ($data);} /* Recommended Channel recommended user */function Recommenduser () {//If it is auto-recommended mode if ($this->yb[' recomm_switch ']! = 1) {$data = Spclass (' Db_tags_ Blog ')->finduserbytid ($this->spargs (), $this->uid), foreach ($data [' Data '] as & $d) {$d [' h_url '] = Gouserhome (' uid ' = ' $d [' uid '], ' domain ' = ' $d [' domain ']), $d [' h_img '] = Avatar (' uid ' + $d [' uid '], ' size ' = ' big '), $d [' logtime '] = ybtime (Array (' time ' = $d [' LogTime ']), $d [' sign '] = strip_tags ($d [' sign ']); $d [' isfollow '] = ($d [' isfollow '] = = $this->uid)? true:false; $d [' blogtag '] = ($d [' blogtag ']! = ')? Explode (', ', $d [' Blogtag ']): ';}} else{} $this->api_success ($data);} /* Home Get comments */function reply () {$bid = $this->spargs (' bid '); $result = Spclass (' Db_replay ')->splinker ()->sppager ($this->spargs (' page ', 1), $this->spargs (' limit ', ten))->findall (' bid ' + $bid), ' Time desc ', '); $ Pager = "; $data = Array (); $data [' page '] = Spclass (' Db_replay ')->sppager ()->getpager (); foreach ($result as &$ d) {$d [' msg '] = Strip_tags (strreplaces ($this->parse_uid ($d [' msg])); $d [' h_url '] = gouserhome (' uid ' + $d [' uid '], ' domain ' = $d [' domain ']), $d [' h_img '] = Avatar (' uid ' = ' $d [' uid '], ' size ' = ' small ')); $d [' Time '] = ybtime (Array (' time ' = = $d [' time ']); $d [' del_flag '] = IsLogin ()? 1:0; $d [' rep_flag '] = ($this->uid! = $d [' uid '] && $this->uid! = ")? 1:0;} $data [' body '] = $result; $this->api_success ($data);} Handles feeds to the front display//$split whether to truncate the contents of the Private Function foramt_feeds (& $d, $split =1) {$d [' more '] = 0; $d [' h_url '] = Gouserhome ( Array (' uid ' = = $d [' uid '], ' domain ' = $d [' domain ']), $d [' h_img '] = Avatar (' uid ' = ' $d [' uid '], ' size ' = ' Middle '); $d [' b_url '] = Gouserblog (' bid ' + $d [' Bid '], ' domain ' = ' $d [' domain '], ' uid ' = ' $d [' uid ']); $d [' tag '] = ($d [' tag ']! = ')? Explode (', ', $d [' tag ']): '; $d [' time_y '] = date (' y.m ', $d [' time ']), $d [' time_d '] = date (' d ', $d [' time ']); $d [' time '] = YBT IME (Array (' time ' = $d [' time ']); $rs = Split_attribute ($d [' body ']); $d [' attr '] = $rs [' attr '], $d [' repto '] = $rs [' Repto '];if (!empty ($d [' Repto '])) {$d [' repto '] [' h_url '] = gouserhome (Array ( ' UID ' = $d [' Repto '] [' uid '], ' domain ' = ' $d [' repto '] [' domain ']), $d [' Repto '] [' h_img '] = Avatar (Array (' uid ' = $d [' Repto '] [' uid '], ' size ' = ' small ')); else{$d [' repto '] = null;} if ($split = = 1) {$d [' body '] = UTF8_SUBSTR (strip_tags ($rs [' body '], ' 

'), 0,500);} else{$d [' body '] = strip_tags ($rs [' body '], '

');} if ($d [' body '] = = False) {$d [' body '] = ';} $d [' more '] = (Utf8_strlen ($rs [' body ']) > 500)? 1:0;//processing music and video if ($d [' type '] = = 2 | | $d [' type '] = = 4) {if (count ($d [' attr ']) > 4) {$d [' mode '] = 1;if ($split = = 1) {$d [' attr ' ] = Array_slice ($d [' attr '],0,4);}}} Processing pictures, more than 10 tasks Moreif ($d [' type '] = = 3) {if ($split = = 1) {if ($d [' attr '] [' count '] >) {$d [' attr '] [' img '] = array_slice ($d [' attr '] [' img '],0,10); $d [' mode '] = 1;}}} If show all then change more to 0if ($split! = 1) {$d [' show_reply '] = 1;//expand comments}}


Reply to discussion (solution)

The code you posted just how to get the data
Does not give the data how to write to the template

The code you posted just how to get the data
Does not give the data how to write to the template
This is the template is JS call, I do not want to use JS call, want to write directly into the template

{include file= "theme/default/header.html" titles= $data. Title} {include file= "require_models_js.html"}    {include file= "theme/default/userheader.html"} {if!empty ($data. 0.tag)} {foreach $data. 0.tag as $d}    
  • {$d}
  • {/foreach} {/if} {if Isset ($adunit. 6) && $adunit 6.is_show = = 1} {/if} who likes {$fava. Count}{if $fava. Count!=0}{foreach from= $fava. Rs Item=d}{/foreach} {/if} {include File= "theme/default/aside.html"}{include file= "theme/default/footer.html"}

    Then you need to see the HTML code that arrives in the browser and analyze how the data is read

    Then you need to see the HTML code that arrives at the browser and analyze how the data is read. You look at this site www.shanzhaicun.com

    It's like this yb_load_feeds function, put out his code.
    You have those compact format JS See people hair Dizzy

    It's like this yb_load_feeds function, put out his code.
    You have those compact format JS look people hair dizzy I can't find this

    It's like this yb_load_feeds function, put out his code.
    You those compact format JS See people hair dizzy see such code is not what you want to see

    Template (' feed_template ', ' {each blog as data i} {include tpl_header_define (\ ' header\ ') data} {include Tpl_feed_define (d Ata.type) Data} {if data.show_reply ==1} {include tpl_header_define (\ ' infooter\ ') data} {else} {include Tpl_header_ Define (\ ' Footer\ ') data} {/if} {/each} '); template (' Tmpl_model_header ', ' {time_y}{time_d} {if top ==1}[\u7f6e\u9876]{/ If}{if title! = null}{title}{/if} '); template (' Tmpl_model_1 ', '

    {if Attr.length >0} {Each attr as img i} {If I <1} {/if} {/each} {/if} {Body}

    Template (' tmpl_model_2 ', ' {if attr.length > 0} {Each attr as M i} {if m.type = = \ ' local\ '} {m.title}-{M.auth Or\u4e0b\u8f7d\u97f3\u4e50 {/if} {if M.type = = \ ' xiamisearch\ ' | | m.type = = \ ' Xiami\ '} {if m.title! = \ ' null\ ' && m.author! = \ ' Null\ '} {m.title} {M.author} {/if}\u5f39\u51fa\u64ad\u653e{if M.type = = \ ' Xiami\ '}{Else}{/if} {/if} {if M.type = = \ ' Yinyuetai\ '} {m.title} {M.author} {/if} {/each} {/if} {if Body}

    {Body}

    {/if} ');
  • 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.