Jump to content

need rss code for knowledgebase.


Recommended Posts

how to count one article as popular by views or useful votes?

 

i'm not sure how you can integrate it with WordPress but to get the top articles we can query our database by create new file in client area let's name it kbapi.php or something else and add the following code inside it:

 

<?php
define("CLIENTAREA",true);
require("init.php");

header("Content-Type: application/json; charset=utf-8");

$output = array();

# Get Articles based on views
$select_articles = full_query("SELECT * FROM `tblknowledgebase` WHERE `private`!='on' AND `parentid`='0' ORDER BY `views` DESC LIMIT 5");
while ($article = mysql_fetch_assoc($select_articles)){
   $output[] = array(
       "id" => $article['id'],
       "title" => stripslashes($article['title']),
       "article" => html_entity_decode(stripslashes($article['article'])),
       "views" => $article['views'],
       "url" => $CONFIG['SystemURL'] . '/knowledgebase.php?action=displayarticle&id='.$article['id']
   );
}

echo json_encode($output);

?>

 

this will give you the top five articles based on views, also the output is set to JSON format this way you can integrate it easily using Javascript if you which

Link to comment
Share on other sites

how to count one article as popular by views or useful votes?

 

i'm not sure how you can integrate it with WordPress but to get the top articles we can query our database by create new file in client area let's name it kbapi.php or something else and add the following code inside it:

 

<?php
define("CLIENTAREA",true);
require("init.php");

header("Content-Type: application/json; charset=utf-8");

$output = array();

# Get Articles based on views
$select_articles = full_query("SELECT * FROM `tblknowledgebase` WHERE `private`!='on' AND `parentid`='0' ORDER BY `views` DESC LIMIT 5");
while ($article = mysql_fetch_assoc($select_articles)){
   $output[] = array(
       "id" => $article['id'],
       "title" => stripslashes($article['title']),
       "article" => html_entity_decode(stripslashes($article['article'])),
       "views" => $article['views'],
       "url" => $CONFIG['SystemURL'] . '/knowledgebase.php?action=displayarticle&id='.$article['id']
   );
}

echo json_encode($output);

?>

 

this will give you the top five articles based on views, also the output is set to JSON format this way you can integrate it easily using Javascript if you which

 

thanks you , create kb.ph and copy code into file , but cant opened file and get error.

Link to comment
Share on other sites

sorry , kbapi.php . get bellow error :

 

Tahoma,sans-serif; color: #333333;\" lang=\"FA\">\u062a\u0627 \u0627\u0632 \u062a\u0645\u0627\u0645\u06cc \u0627\u0645\u06a9\u0627\u0646\u0627\u062a \u0627\u0648\u0646 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u062f\u00a0<\/span><span style=\"font-family: Tahoma,sans-serif; color: #333333;\">.<\/span><\/span> <\/span><\/div>","views":"533","url":"http:\/\/my.mysitename.com\/knowledgebase.php?action=displayarticle&id=4"}]

Link to comment
Share on other sites

it's JSON no errors, i made it this way so it will be easy for you to parse it using PHP or Javascript, as you currently use Wordpress it will be easy to you to edit your theme files header/footer add cURL function that parse this data into WordPress

 

or use AJAX if you which to use Javascript instead

Link to comment
Share on other sites

i need example code , this code read rss post ,

 

<ul>

 

<?php

include_once(ABSPATH . WPINC . '/rss.php');

$rss = fetch_rss('http://www.mysitename.com/feed');

$maxitems = 10;

$items = array_slice($rss->items, 0, $maxitems);

?>

<ul>

<?php if (empty($items)) echo '<li>no post</li>';

else

foreach ( $items as $item ) : ?>

<li><a href='<?php echo $item['link']; ?>'

title='<?php echo $item['title']; ?>'>

<?php echo $item['title']; ?>

</a></li>

<?php endforeach; ?>

 

</ul>

Link to comment
Share on other sites

from the RSS link that sentq gave, have you tried replacing the SQL query...

 

$result = mysql_query("SELECT * FROM tblknowledgebase");

which is showing all articles, with the SQL query specified by sentq in his above post?

 

$result = full_query("SELECT * FROM `tblknowledgebase` WHERE `private`!='on' AND `parentid`='0' ORDER BY `views` DESC LIMIT 5");

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated