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

* Navigator

Expand - Collapse

* Statistic


  • *Total Posts: 16431
  • *Total Topics: 2522
  • *Online Today: 7
  • *Most Online: 292
(12. Nov 2016, 09:37:31)
  • *Users: 1
  • *Guests: 0
  • *Spiders: 2
  • *Total: 3

* Calendar

Mo
Tu
We
Th
Fr
Sa
Su
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

Blog feed block

Started by Atheos, 17. Dec 2009, 21:33:49

previous topic - next topic

0 Members and 0 Guests are viewing this topic.

Atheos

17. Dec 2009, 21:33:49
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
17. Dec 2009, 22:15:04
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
17. Dec 2009, 22:51:11
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
18. Dec 2009, 01:02:44
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
18. Dec 2009, 22:15:57
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
19. Dec 2009, 01:07:14
Quote from: KB on 18. Dec 2009, 22:15:57
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
19. Dec 2009, 15:59:15
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
19. Dec 2009, 21:22:29
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
19. Dec 2009, 22:36:52
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
19. Dec 2009, 23:31:29
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
20. Dec 2009, 04:49:02
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
20. Dec 2009, 23:23:49
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
21. Dec 2009, 11:19:15
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
21. Dec 2009, 18:21:44
Thank you! Thank you!

KB

#14
05. Jan 2010, 21:20:21
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!