创建 RSS/XML 数据源
我正在尝试创建一个提要数据源,以便更轻松、更清晰地获取提要,并作为学习 Cake 框架的一些新知识的一种方式。
我让数据源按我想要的方式工作,它返回项目,但是我希望能够使用不同的提要实例化它,这样我就不需要为每个提要创建新的数据源。我将联合大约 5 个不同的提要。
我正在考虑在 app/config/core.php
中定义它们,然后将您想要的作为查找中的条件传递给它们,但我宁愿将其放在比控制器中更低的位置。
请问有什么想法吗?
在这里上传了我的代码, https://bitbucket.org/davidyell/cakephp- feedsource/src/4010d393af1b/FeedSource.php
I am trying to create a feeds data source to make getting feeds easier and cleaner, and as a way to learn some new bits and bobs of the Cake framework.
I have the datasource working as I'd like, it returns items, however I'd like to be able to instantiate it with different feeds so that I don't need to create a new data source for each feed. I'm going to be syndicating about 5 different feeds.
I was thinking about defining them in the app/config/core.php
and then passing in which one you wanted as a condition in the find, but I'd rather do it lower down than in the controller.
Any idea's please?
Uploaded my code here, https://bitbucket.org/davidyell/cakephp-feedsource/src/4010d393af1b/FeedSource.php
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
数据源通常从 DATABASE_CONFIG 类获取配置设置。您可以在那里定义 rss url 或将参数从模型传递到数据源。查看 LoadSys 的 RSS 数据源,为您提供一些关于什么是这样做的好方法。
Datasources usually pick up configuration settings from the DATABASE_CONFIG class. You could define the rss urls there or pass a parameter from your Model to the Datasource. Take a look at LoadSys' RSS Datasource to give you some hints as to what would be a good way to do this.