如何使用codeigniter制作rss [英] how to make rss using codeigniter

查看:81
本文介绍了如何使用codeigniter制作rss的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi2all我有像数组一样的数据



 object(stdClass)[ 33 ] 
public ' id' => string ' 31'(length = 2)
public ' title_english' => string ' 销售和营销'(长度= 19)
public ' title_arabic' => string ' تسويقومبيعات'(length = 26)
public ' slug' => string ' sales-and-marketing'(length = 19)
public ' meta' => string ' dvd'(length = 3)
public ' parent' => string ' 0'(length = 1)
public ' image' => string ' '(length = 0)
公开 ' status' => string ' pending'(length = 7)
public ' title' => string ' tawrny maintance'(length = 16)
public ' user_id' => string ' 4'(length = 1)
public ' description' => string ' nb,fmf,f ,, fm,fm'(length = 15)
public ' keywords' => string ' ddddddddd'(length = 9)
public ' category_id' => string ' 1'(length = 1)
public ' type' => string ' fixed'(length = 5)
public ' budget_min' => string ' 1.00'(length = 4)
public ' budget_max' => string ' 0.00'(length = 4)
public ' created_at' => string ' 2014-02-17 16:38:16'(length = 19)
public ' updated_at' => string ' 2014-02-17 16:47:02'(length = 19)
public ' closed_at' => string ' 2014-02-24 16:38:16'(length = 19)
public ' duration' => string ' 0'(length = 1)
public ' file' => string ' freelancer.sql'(length = 14)
public ' upgrade' => string ' 1'(length = 1)





i想要输出所有数据

我在我的视图中使用该代码

///////// //////////



 <?php  
echo ' <?xml version =1.0encoding =utf-8?>' \ n;
?>


< < span class =code-leadattribute> rss version = 2.0

xmlns:dc = http://purl.org/dc/elements/1.1/

< span class = code-attribute> xmlns:sy = http://purl.org/rss/1.0 / modules / syndication /

xmlns:admin = < span class =code-keyword> http://webns.net/mvcb/

xmlns:rdf = http://www.w3.org/1999/02/22-rdf-syntax-ns#

xmlns:content = http:// purl。 org / rss / 1.0 / modules / content / >

< ; 频道 >

< title > <? php echo $ feed_name ; ?> < / title < span class =code-keyword>>
< link > <? php echo < span class =code-sdkkeyword> $ feed_url ; ?> < / link < span class =code-keyword>>
< de script ion > <? php echo $ page_description ; ?> < / de < span class =code-leadattribute> script ion >
< span class =code-keyword>< dc:language > <? php echo $ page_language ; ?> < / dc:language >
< dc:creator > <? php echo $ creator_email ; ?> < / dc:creator >
< dc:rights > 版权所有<? php echo gmdate( Y,time()); ?> < / dc:rights >

< admin:generatorAgent rdf:resource = http://www.codeigniter.com/ / >

<? php foreach($ posts-> result() as $ entry):?>

< item >
< title > <? php echo xml_convert($ entry-> title); ?> < / title < span class =code-keyword>>
< link > <? php echo site_url (' blog / post /'。$ entry-> id)?> < / link >
< guid isPermaLink = true > <? php echo site_url(' 博客/帖子/'。 $ entry-> id)?> < / guid >

< de script ion > < ![CDATA [<?php echo character_limiter( $ entry - > text,200); ?> < / de script ion >
< pubDate > <? php echo date(' r',$ entry-> date); ?> < / pubDate >

< / item >

<? php endforeach; ?>

< / admin:generatoragent >

< < span class =code-leadattribute> / channel >

< ; / rss >







////////////////////



输出是



http://freelancer.dev/

khdmat项目

tawrny maintance(这是该项目的英文名称)

nb,fmf,f ,, fm,fm(这是描述)

解决方案

< BLOCKQUOTE> FEED_NAME ; ?> < / title < span class =code-keyword>>
< link > <? php echo < span class =code-sdkkeyword>


feed_url ; ?> < / link < span class =code-keyword>>
< de script ion > <? php echo


page_description ; ?> < / de < span class =code-leadattribute> script ion >
< span class =code-keyword>< dc:language > <? php echo


hi2all i have data in array like that

object(stdClass)[33]
          public 'id' => string '31' (length=2)
          public 'title_english' => string 'Sales and Marketing' (length=19)
          public 'title_arabic' => string 'تسويق و مبيعات' (length=26)
          public 'slug' => string 'sales-and-marketing' (length=19)
          public 'meta' => string 'dvd' (length=3)
          public 'parent' => string '0' (length=1)
          public 'image' => string '' (length=0)
          public 'status' => string 'pending' (length=7)
          public 'title' => string 'tawrny maintance' (length=16)
          public 'user_id' => string '4' (length=1)
          public 'description' => string 'nb,fmf,f,,fm,fm' (length=15)
          public 'keywords' => string 'ddddddddd' (length=9)
          public 'category_id' => string '1' (length=1)
          public 'type' => string 'fixed' (length=5)
          public 'budget_min' => string '1.00' (length=4)
          public 'budget_max' => string '0.00' (length=4)
          public 'created_at' => string '2014-02-17 16:38:16' (length=19)
          public 'updated_at' => string '2014-02-17 16:47:02' (length=19)
          public 'closed_at' => string '2014-02-24 16:38:16' (length=19)
          public 'duration' => string '0' (length=1)
          public 'file' => string 'freelancer.sql' (length=14)
          public 'upgrade' => string '1' (length=1)



i want to output all that data
i'm using that code in my view
///////////////////

<?php 
echo '<?xml version="1.0" encoding="utf-8"?>' . "\n";
?>


<rss version="2.0"

     xmlns:dc="http://purl.org/dc/elements/1.1/"

     xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"

     xmlns:admin="http://webns.net/mvcb/"

     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

     xmlns:content="http://purl.org/rss/1.0/modules/content/">  

    <channel>

        <title><?php echo $feed_name; ?> </title> 
        <link><?php echo $feed_url; ?> </link> 
        <description><?php echo $page_description; ?></description>  
        <dc:language><?php echo $page_language; ?></dc:language>  
        <dc:creator><?php echo $creator_email; ?></dc:creator>
        <dc:rights>Copyright <?php echo gmdate("Y", time()); ?></dc:rights>  

        <admin:generatorAgent rdf:resource="http://www.codeigniter.com/" />
  
        <?php foreach($posts->result() as $entry): ?>  

            <item>  
                <title><?php echo xml_convert($entry->title); ?></title> 
                <link><?php echo site_url('blog/post/' . $entry->id) ?></link>
                <guid isPermaLink="true"><?php echo site_url('blog/post/' . $entry->id) ?></guid>

                <description><![CDATA[<?php echo character_limiter($entry->text, 200); ?></description>
                <pubDate><?php echo date ('r', $entry->date);?></pubDate>

            </item>  

        <?php endforeach; ?>

        </admin:generatoragent>

    </channel>

</rss> 




////////////////////

the output is

http://freelancer.dev/
khdmat projects
tawrny maintance(this is the english title of the project)
nb,fmf,f,,fm,fm (this is the description)

解决方案

feed_name; ?> </title> <link><?php echo


feed_url; ?> </link> <description><?php echo


page_description; ?></description> <dc:language><?php echo


这篇关于如何使用codeigniter制作rss的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆