To use this website completely, it is necessary to store cookies on your computer.
 

* Navigator

Expand - Collapse

* Statistic

  • *Total Posts: 14944
  • *Total Topics: 2271
  • *Online Today: 10
  • *Most Online: 292
(2016 November 12, 09:37:31 am)

Blog feed block

Started by Atheos, 2009 December 17, 09:33:49 pm

previous topic - next topic

0 Members and 0 Guests are viewing this topic.

Atheos

2009 December 17, 09:33:49 pm
Hello. I'm sorry if this has been asked and I missed it. I am looking for anway to feed certain blogs or recent blogs to a block on my frontpage. Is this possible?  Maybe with RSS feed? Thank you.

feline

#1
2009 December 17, 10:15:04 pm
with the RSS Reader block you can read feeds from any page the have a rss feed.

Fel
Many are stubborn in relation to the path, a few in relation to the target.

Atheos

#2
2009 December 17, 10:51:11 pm
Fel, how can I set this up to have five most recent blogs fed to block?

Edit: I'm sorry. I should have stated that it is the portamx blogs I want to feed to a frontpage block.

feline

#3
2009 December 18, 01:02:44 am
If you have PmxBlog installed, you can use the PmxBlogSSI.php to get articles in a php block.
In you forum root you find two examples how to use the PmxBlogSSI ... PmxBlogSSI_example.php and PmxBlogSSI_example.shtml

Fel
Many are stubborn in relation to the path, a few in relation to the target.

KB

#4
2009 December 18, 10:15:57 pm
Feline:
Thanks for PortaMX..works great with my SMF 2.0 rc2 site.

I feel sort of embarassed to ask, but Im not much on php and continue to get parse errors attempting to get a block to read blog posts, so I know Im messing it up even with your examples.  Could you please post a working snipplet to get me on the right track?  Thx

Atheos

#5
2009 December 19, 01:07:14 am
Quote from: KB ,  2009 December 18, 10:15:57 pm
Feline:
Thanks for PortaMX..works great with my SMF 2.0 rc2 site.

I feel sort of embarassed to ask, but Im not much on php and continue to get parse errors attempting to get a block to read blog posts, so I know Im messing it up even with your examples.  Could you please post a working snipplet to get me on the right track?  Thx


Same here. Good to see someone else is interested in this as well. I don't mean to be a nuisance but I'm a novice at this stuff. Could someone provide a quick example?

feline

#6
2009 December 19, 03:59:15 pm
The PmxBlogSSI functions are described in the example files, the functionality is the same as on the SMF SSI.
For more help I need a exactly information, what you want to show in a block.

Fel
Many are stubborn in relation to the path, a few in relation to the target.

KB

#7
2009 December 19, 09:22:29 pm
Thx Feline for the response. 8)

Im afraid that altho it may be clear for you and anyone other than us "php challenged" people...I just cant get the right code extracted from the html example files.  It seemed simple enough at first, but I know Im missing something. 
Id take just about any kind of function example right now.  My main objective however will be to show recent entries from my own blog..not sure at this time if there will be any other authors on my site other than myself.

Cool

#8
2009 December 19, 10:36:52 pm
this code in a php block:
Code Select
include_once('PmxBlogSSI.php');
PmxBlogSSI_Recent();

 |I Use: SMF 2.0.5 | PortaMx 1.51
Q: What do you do when you see a bear in the woods?
A: Play Dead!
H-A-H-L = Happy Admins Have Linux

feline

#9
2009 December 19, 11:31:29 pm
The follow is a sample code to get n recent blog articles.
Put this in a php block...
Code Select

include_once('PmxBlogSSI.php');
global $smcFunc, $user_info, $txt;

$maxarticles = 5; // max articles to show

if(AllowedToBlog('view'))
{
$result = array();
$req = $smcFunc['db_query']('', '
SELECT c.ID, c.subject
FROM {db_prefix}pmxblog_content AS c
LEFT JOIN {db_prefix}members AS m ON (c.owner = m.id_member)
LEFT JOIN {db_prefix}pmxblog_manager AS a ON (c.owner = a.owner)
WHERE a.blogenabled > 0 AND a.bloglocked = 0 AND c.published = 1
AND (c.allow_view = 0
OR (c.allow_view = 1 AND {int:idmem} > 0)
OR (c.allow_view = 2 AND {string:s_idmem} IN (m.buddy_list))
OR (c.allow_view = 3 AND c.owner = {int:idmem})
OR (c.owner = {int:idmem}))
GROUP BY c.ID
ORDER BY c.date_created DESC
LIMIT {int:lim}',
array(
's_idmem' => (string) $user_info['id'],
'idmem' => $user_info['id'],
'lim' => $maxarticles,
)
);
if($smcFunc['db_num_rows']($req) > 0)
{
$i = 0;
while($row = $smcFunc['db_fetch_assoc']($req))
{
$result[$i] = array('id' => $row['ID'], 'subject' => $row['subject']);
$i++;
}
$smcFunc['db_free_result']($req);
}

// link requested?
if(isset($_REQUEST['blogcont']))
$artid = (int) $_REQUEST['blogcont'];
elseif(!empty($result))
$artid = $result[0]['id'];
else
{
echo '
'. $txt['PmxBlog_nothing_read'];
return;
}

// get the selected article data
$article = PmxBlogSSI_GetArticle($artid, '');
PmxBlogArticles_SSI_Out($article, $result, $artid);
}


That show as you see in the attached image.

Fel


[attachment deleted by admin]
Many are stubborn in relation to the path, a few in relation to the target.

KB

#10
2009 December 20, 04:49:02 am
AWESOME! O0 Thanks Feline and Cool!
Works great as front page or center block..and Cool, thats exactly what I was looking for use in a side block.

Atheos

#11
2009 December 20, 11:23:49 pm
Fel, this works great  but is there a way to make it show a teaser about 40-100 words long instead of the entire article? Thanks again!!

feline

#12
2009 December 21, 11:19:15 am
Yes, try this ..
Code Select

include_once('PmxBlogSSI.php');
global $context, $smcFunc, $user_info, $txt;

$maxarticles = 5; // max articles to show
$context['PmxBlog']['content_len'] = 40; // Teaser length

if(AllowedToBlog('view'))
{
$result = array();
$req = $smcFunc['db_query']('', '
SELECT c.ID, c.subject
FROM {db_prefix}pmxblog_content AS c
LEFT JOIN {db_prefix}members AS m ON (c.owner = m.id_member)
LEFT JOIN {db_prefix}pmxblog_manager AS a ON (c.owner = a.owner)
WHERE a.blogenabled > 0 AND a.bloglocked = 0 AND c.published = 1
AND (c.allow_view = 0
OR (c.allow_view = 1 AND {int:idmem} > 0)
OR (c.allow_view = 2 AND {string:s_idmem} IN (m.buddy_list))
OR (c.allow_view = 3 AND c.owner = {int:idmem})
OR (c.owner = {int:idmem}))
GROUP BY c.ID
ORDER BY c.date_created DESC
LIMIT {int:lim}',
array(
's_idmem' => (string) $user_info['id'],
'idmem' => $user_info['id'],
'lim' => $maxarticles,
)
);
if($smcFunc['db_num_rows']($req) > 0)
{
$i = 0;
while($row = $smcFunc['db_fetch_assoc']($req))
{
$result[$i] = array('id' => $row['ID'], 'subject' => $row['subject']);
$i++;
}
$smcFunc['db_free_result']($req);
}

// link requested?
if(isset($_REQUEST['blogcont']))
$artid = (int) $_REQUEST['blogcont'];
elseif(!empty($result))
$artid = $result[0]['id'];
else
{
echo '
'. $txt['PmxBlog_nothing_read'];
return;
}

// get the selected article data
$article = PmxBlogSSI_GetArticle($artid, '');
$article['body'] = Post_Teaser($article['body']); // call the teaser
PmxBlogArticles_SSI_Out($article, $result, $artid);
}


Fel
Many are stubborn in relation to the path, a few in relation to the target.

Atheos

#13
2009 December 21, 06:21:44 pm
Thank you! Thank you!

KB

#14
2010 January 05, 09:20:21 pm
One more question please :)

If there are more than one members using the blog system, can the block codes be changed to display ONE selected authors blog rather than 'all' recent articles from all blogs?

Thanks!

feline

#15
2010 January 05, 09:42:30 pm
you can try this PmxBlogSSI function ...

/**
* PmxBlogSSI_ShowArticles()
* owner: integer ownerID or ownerName
* mindate: integer unixdate OR string 'mon.day.year' (0 not used)
*            string date: mon{1-12}, day{1-31}, year{4 digit})
* maxdate: integer unixdate OR string 'mon.day.year' (0 not used)
*            string date: mon{1-12}, day{1-31}, year{4 digit})
* categorie: id or name (0 not used)
* maxlen: integer max articles to show (0 = all)
* output: 'echo' or empty
**/

Fel
Many are stubborn in relation to the path, a few in relation to the target.

KB

#16
2010 January 06, 12:18:21 am
Thanks Fel..but you seem to forget that Im php challenged.. ;)
I tried to use cools example for a side block and modified the code as follows, but of course, got a syntax error, so I know Ive left something important out..doh!
Code Select
include_once('PmxBlogSSI.php');
PmxBlogSSI_ShowArticles(owner:2);

Id like to have both the simple side block (as cool mentioned) and also the frontpage or center block example that you provided earlier....only of course with the single user format. 
thx again!!

feline

#17
2010 January 06, 12:41:19 am
the call must defines as PmxBlogSSI_ShowArticles(2); where 2 is the owner ID.

Also you can take a look at the sample files you found in your forum root  ;)

Fel
Many are stubborn in relation to the path, a few in relation to the target.

KB

#18
2010 January 06, 06:51:36 am
Great!!  Thanks Fel...that works better,
Code Select
include_once('PmxBlogSSI.php');
PmxBlogSSI_ShowArticles(2);
but displays too much for a side block.(see attached pmx_blog_sideblock2.jpg)  I was hoping that by using cools' example as a starting point (because it only displays title, author, date/time as in attached pmx_blog_sideblock1.jpg) that it would work similarly to the way his original code does (less info, trunicated or no content, without calendar or categories) ,  sorry I did look into the samples again, but Im just not sure what code to use in order to make it work. 

[attachment deleted by admin]

feline

#19
2010 January 06, 01:45:51 pm
I have modified the recent Function, to get only recent blogs from a specific user.
Copy the attached PmxBlog.SSI.php to your server (overwrite the exist file).
Then make a php Block with follow content
Code Select

include_once('PmxBlogSSI.php');
PmxBlogSSI_Recent(5, 1);

where 5 is the number of recent articles and 1 is the userid which blogs you will see.
Of course you have to set this to your values  ;)

Fel

[attachment deleted by admin]
Many are stubborn in relation to the path, a few in relation to the target.

KB

#20
2010 January 06, 08:58:11 pm
Thanks So much Fel...I really appreciate the support you have provided for me and see the same effort being given to each and every person who asks...that says a lot for you and for portamx.   O0
Ill give this a shot and let ya know how it goes, but Im sure its exactly what the doc ordered..lol..THANKS AGAIN!

KB

#21
2010 January 07, 09:23:16 am
Works like a charm!! Thanks Again! 8)

kcmartz

#22
2010 January 27, 09:18:44 pm
Code Select

include_once('PmxBlogSSI.php');
PmxBlogSSI_Recent(5, 1);


I would like it to show for a certain few members, is this the correct syntax?:
Code Select

include_once('PmxBlogSSI.php');
PmxBlogSSI_Recent(5, 1,2,3);


Thanks!
If not, what does it look like to make it from a certain few members that I select?
Thanks,
Kcmartz

feline

#23
2010 January 27, 11:38:59 pm
That don't work. Recent blogs is the same as recent post, it show the last posted blogs.
With the change they I have posted you can see the recent for ONE member, but not for a list of member.

Fel
Many are stubborn in relation to the path, a few in relation to the target.

ileami

#24
2010 February 13, 12:44:04 pm
Hi all, I've tried to add this code on a SMF portal block
Quote from: feline ,  2009 December 21, 11:19:15 am
Yes, try this ..
Code Select

include_once('PmxBlogSSI.php');
global $context, $smcFunc, $user_info, $txt;

$maxarticles = 5; // max articles to show
$context['PmxBlog']['content_len'] = 40; // Teaser length

if(AllowedToBlog('view'))
{
$result = array();
$req = $smcFunc['db_query']('', '
SELECT c.ID, c.subject
FROM {db_prefix}pmxblog_content AS c
LEFT JOIN {db_prefix}members AS m ON (c.owner = m.id_member)
LEFT JOIN {db_prefix}pmxblog_manager AS a ON (c.owner = a.owner)
WHERE a.blogenabled > 0 AND a.bloglocked = 0 AND c.published = 1
AND (c.allow_view = 0
OR (c.allow_view = 1 AND {int:idmem} > 0)
OR (c.allow_view = 2 AND {string:s_idmem} IN (m.buddy_list))
OR (c.allow_view = 3 AND c.owner = {int:idmem})
OR (c.owner = {int:idmem}))
GROUP BY c.ID
ORDER BY c.date_created DESC
LIMIT {int:lim}',
array(
's_idmem' => (string) $user_info['id'],
'idmem' => $user_info['id'],
'lim' => $maxarticles,
)
);
if($smcFunc['db_num_rows']($req) > 0)
{
$i = 0;
while($row = $smcFunc['db_fetch_assoc']($req))
{
$result[$i] = array('id' => $row['ID'], 'subject' => $row['subject']);
$i++;
}
$smcFunc['db_free_result']($req);
}

// link requested?
if(isset($_REQUEST['blogcont']))
$artid = (int) $_REQUEST['blogcont'];
elseif(!empty($result))
$artid = $result[0]['id'];
else
{
echo '
'. $txt['PmxBlog_nothing_read'];
return;
}

// get the selected article data
$article = PmxBlogSSI_GetArticle($artid, '');
$article['body'] = Post_Teaser($article['body']); // call the teaser
PmxBlogArticles_SSI_Out($article, $result, $artid);
}


Fel

but I got db error..
any help/suggestion?
Thanks
Lia