Giter Club home page Giter Club logo

Comments (5)

joyqi avatar joyqi commented on June 2, 2024

这种获取内容的方式本来就是错误的,并没有推荐过这种方式

from typecho.

Moidea avatar Moidea commented on June 2, 2024

嗯,更新typecho时发现有些早期的主题还有插件使用过这种方法从数据库中读取指定id的文章数据信息,如果改进是不是只能通过读取路由表来组合文章链接了

function GetIdPosts($id){
    if($id){
        $getid = explode(',',$id);    
        $db = Typecho_Db::get();
        $result = $db->fetchAll($db->select()->from('table.contents')
            ->where('status = ?','publish')
            ->where('type = ?', 'post')
            ->where('cid in ?',$getid)
            ->order('cid', Typecho_Db::SORT_DESC)        
        );
        if($result){
            $i=1;
            foreach($result as $val){                
                $val = Typecho_Widget::widget('Widget_Abstract_Contents')->push($val);
                $post_title = htmlspecialchars($val['title']);
                $permalink = $val['permalink'];
                echo '<li><a href="'.$permalink.'" title="'.$post_title.'" target="_blank">'.$post_title.'</a></li>';
            }
        }
    }else{
        echo '请设置要调用的文章ID';
    }
}

from typecho.

jrotty avatar jrotty commented on June 2, 2024

可以用这个方法Helper::widgetById('Contents', $cid);

from typecho.

joyqi avatar joyqi commented on June 2, 2024

可以用这个方法Helper::widgetById('Contents', $cid);

这是推荐的方式,建议采用

from typecho.

Moidea avatar Moidea commented on June 2, 2024

Helper::widgetById('Contents', $cid);

谢了,这个方法好用

from typecho.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.