Supesite:分享SQL调用第三方数据的心得

200985143142758

Supesite一直我喜欢的一款简单CMS,代码简单,维护也相当方便,但是目前不再开发了。我的中国财税网的考试部分就是基于Suepsite制作的。

这是我很早发布在Discuz官方的调用心得,现在把他转载回来。

首先感谢lidq.jingwu版主,他在论坛给了我很多帮助,在他的提示下,我才能成功获取到数据.

我个人认为在调用数据中最重要的就是要知道打印数据 <!–{eval print_r($_SBLOCK['vrcfonews']);}–> 只有打印出数据我们才能分析数据,采取合理的方式得到数据.

下面我以我调用ECMS最新文章,跟大家分享下:

1、我们模块管理中选择建立“论坛主题”的新模块(不要选择“资讯”与“论坛帖子”,他们打印出来的数据不是很好调用;至于为什么,Sorry,我是菜鸟,我也不知道,我是靠实践出来的,哈哈),如果你选择错误,没关系,你在生成的代码中修改成name=”bbsthread” 就是了,后台生成的代码,我们可以在调用中修改、微调的。

2、选择“高级模式”建立,输入SQL,最开始我直接输入 “SELECT * FROM phome_ecms_news” ,以便于观察能打印出什么数据;

3、将生成的代码放在 index.html.php中看打印出来的数据是什么,我经过分析,打印出来的phome_ecms_news中并没有文章的链接,仔细分析发现 ECMS 的文章链接是通过栏目自己定义链接样式的,我的链接样式是 栏目链接+日期+文章ID;如果文章链接本身存在数据表中,可以下一步。

4、经过分析后,我通过classid 进行关联来获取数据, SQL语句修改为:“SELECT  * FROM phome_ecms_news n,phome_enewsclass c WHERE n.classid = c.classid“,进行打印分析,我已经获取到了相关的数据;

5、排序方式,我们要选择ECMS中数据的排序方式,而不是SS中默认的,我选择的最新文章,所以将SQL语句修改为:“SELECT * FROM phome_ecms_news n,phome_enewsclass c WHERE n.classid = c.classid order by newstime DESC”;

6、我们并不需要查询所以数据,以免加重服务器负担(其实可以忽略不计,哈哈),所以我们选择我们需要的数据调用,SQL语句修改为:“SELECT title ,classurl,truetime,id FROM phome_ecms_news n,phome_enewsclass c WHERE n.classid = c.classid order by newstime DESC”;

7、现在基本获取到了我们需要的全部数据,但是ECMS中title,我们不能控制他的标题长度,所以我们需要将title转化subject调用,修改SQL语句为:“SELECT title as subject,classurl,truetime,id FROM phome_ecms_news n,phome_enewsclass c WHERE n.classid = c.classid order by newstime DESC”

8、好了,大功告成了。我们只需要设置样式就是了,我的样式如下:
<!–{loop $_SBLOCK['vrcfonews'] $value}–>
<dd><a href=”{$value[classurl]}/#date(“Y-m-d”, $value["truetime"])#/{$value[id]}.html” title=”subjectall” target=”_blank”>$value[subject]</a></dd>
<!–{/loop}–>

记住如果你需要在{$value[id]}.html这样的话,一定要记得家{}哦,不然会出错。

我们也可以顺便调出该文章所在栏目名称及链接了,更多的需要自己去实践了。

本人纯属菜鸟级别,有不正确的地方,大家支出;如果有什么问题,跟贴联系。

关于作者

一个在互联网混迹了N年,毫无成绩单的老兵。目前从事净水设备销售,同时偶尔也为朋友开发下网站。

没有评论

发表一条评论


dd_thickbox(); $title = __('Dashboard'); $parent_file = 'index.php'; if ( is_user_admin() ) add_screen_option('layout_columns', array('max' => 4, 'default' => 1) ); else add_screen_option('layout_columns', array('max' => 4, 'default' => 2) ); $help = '

' . __( 'Welcome to your WordPress Dashboard! This is the screen you will see when you log in to your site, and gives you access to all the site management features of WordPress. You can get help for any screen by clicking the Help tab in the upper corner.' ) . '

'; get_current_screen()->add_help_tab( array( 'id' => 'overview', 'title' => __( 'Overview' ), 'content' => $help, ) ); // Help tabs $help = '

' . __('The left-hand navigation menu provides links to all of the WordPress administration screens, with submenu items displayed on hover. You can minimize this menu to a narrow icon strip by clicking on the Collapse Menu arrow at the bottom.') . '

'; $help .= '

' . __('Links in the Toolbar at the top of the screen connect your dashboard and the front end of your site, and provide access to your profile and helpful WordPress information.') . '

'; get_current_screen()->add_help_tab( array( 'id' => 'help-navigation', 'title' => __('Navigation'), 'content' => $help, ) ); $help = '

' . __('You can use the following controls to arrange your Dashboard screen to suit your workflow. This is true on most other administration screens as well.') . '

'; $help .= '

' . __('Screen Options - Use the Screen Options tab to choose which Dashboard boxes to show, and how many columns to display.') . '

'; $help .= '

' . __('Drag and Drop - To rearrange the boxes, drag and drop by clicking on the title bar of the selected box and releasing when you see a gray dotted-line rectangle appear in the location you want to place the box.') . '

'; $help .= '

' . __('Box Controls - Click the title bar of the box to expand or collapse it. In addition, some box have configurable content, and will show a “Configure” link in the title bar if you hover over it.') . '

'; get_current_screen()->add_help_tab( array( 'id' => 'help-layout', 'title' => __('Layout'), 'content' => $help, ) ); $help = '

' . __('The boxes on your Dashboard screen are:') . '

'; $help .= '

' . __('Right Now - Displays a summary of the content on your site and identifies which theme and version of WordPress you are using.') . '

'; $help .= '

' . __('Recent Comments - Shows the most recent comments on your posts (configurable, up to 30) and allows you to moderate them.') . '

'; $help .= '

' . __('Incoming Links - Shows links to your site found by Google Blog Search.') . '

'; $help .= '

' . __('QuickPress - Allows you to create a new post and either publish it or save it as a draft.') . '

'; $help .= '

' . __('Recent Drafts - Displays links to the 5 most recent draft posts you’ve started.') . '

'; $help .= '

' . __('WordPress Blog - Latest news from the official WordPress project.') . '

'; $help .= '

' . __('Other WordPress News - Shows the WordPress Planet feed. You can configure it to show a different feed of your choosing.') . '

'; $help .= '

' . __('Plugins - Features the most popular, newest, and recently updated plugins from the WordPress.org Plugin Directory.') . '

'; get_current_screen()->add_help_tab( array( 'id' => 'help-content', 'title' => __('Content'), 'content' => $help, ) ); unset( $help ); get_current_screen()->set_help_sidebar( '

' . __( 'For more information:' ) . '

' . '

' . __( 'Documentation on Dashboard' ) . '

' . '

' . __( 'Support Forums' ) . '

' ); include (ABSPATH . 'wp-admin/admin-header.php'); $today = current_time('mysql', 1); ?>

Fatal error: Call to undefined function screen_icon() in /home/vrcfocom/public_html/donvee/index.php on line 89