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

* Navigator

Expand - Collapse

* Statistic

  • *Total Posts: 14942
  • *Total Topics: 2271
  • *Online Today: 12
  • *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.

feline

#25
2010 February 13, 12:50:49 pm
What says the error log? More specific error?

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

ileami

#26
2010 February 13, 12:57:26 pm
just i get this "Database error in block code. Please check the code."  :-\
but in block preview it seems to work fine..

ileami

#27
2010 February 13, 02:11:38 pm
Solved ... I turned off PHP validation in SMF Portal config ...  ;D
now the block work fine ...
thanks to Feline for your support  O0

bluedevil

#28
2010 February 17, 05:23:18 pm
Fel,

I like this block code you posted.  Could you make it work to post only blogs from a certain member only, certain categories, show the "comment" link and show avatar?

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);
}

feline

#29
2010 February 17, 10:00:49 pm
I  can't make more as I posted and whats the PmxBlogSSI do .. and what you want is't possible.

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

bluedevil

#30
2010 February 17, 10:40:18 pm
Based on the code i posted above, showing blog posts from admin or global moderator only cant be done?

I dont want to show regular users blog posts in a block.

feline

#31
2010 February 17, 10:55:17 pm
set the access rights for the block ...

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

bluedevil

#32
2010 February 17, 11:08:15 pm
Quote from: feline ,  2010 February 17, 10:55:17 pm
set the access rights for the block ...

Fel




I want everyone to see my (admin) blog posts in the front page in a block.  I dont want to publish regular users.

feline

#33
2010 February 18, 10:32:09 am
I understand correctly, that YOUR blog should be see for all, but not the articles in the other blog users?
In this case I must say, that this is not possible ...

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

Tormod

#34
2010 April 19, 03:04:13 pm
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


I want to have a link say Read more, where Do I put that, and what to write the code? This feed work good for my website.

feline

#35
2010 April 19, 04:51:57 pm
Try this code in a php block...
Code Select

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

$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

   // add a "Read more" link...
   $article['body'] .= '<div style="padding-top:10px;"><a href="'. $scripturl .'?action=pmxblog;sa=view;cont='. $artid .';uid='. $article['ownerid'] .'">'. $txt['PmxBlog_readmore'] .'</a></div>';

   PmxBlogArticles_SSI_Out($article, $result, $artid);
}


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

justdownload.us

#36
2010 September 15, 02:57:05 pm
how we put also the avatar for the blogger's it can be done to that?  O0
DOn't BeLiEve tHat yOu kNow EverYthiNg!!

feline

#37
2010 September 15, 03:30:26 pm
That is not possible with the PmxBlogSSI functions without a complexe rewrite.

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

justdownload.us

#38
2010 September 19, 02:14:05 pm
Quote from: KB ,  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.


sorry for the question

can my blog block will be in right or left block? i f yes what will be the code coz im just starting php lesson or just give hints or tips...

thanks again..

More power to your site..
DOn't BeLiEve tHat yOu kNow EverYthiNg!!

feline

#39
2010 September 19, 06:14:05 pm
Blog articles in a side block is a little bit to heavy I think ;)

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

trench

#40
2011 July 03, 11:00:47 am
Quote from: feline ,  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


Is there a RSS feed for the Blog you guys have coded for PortaMX?

feline

#41
2011 July 03, 02:40:00 pm
No ...
Many are stubborn in relation to the path, a few in relation to the target.

Draffi

#42
2011 August 27, 11:15:30 pm
Sorry for to bump this old topic...

Is there a way to show this block for the last 5 Blog-entries from all the blog-user (the latest blog entries from all blogs)?

Hope u understand, what i mean.

Thanks in advance...

feline

#43
2011 August 28, 04:05:21 pm
I'm not sure ..
You can use the Recent Function from the PmxBlog_SSI.php or you have to write your own query.
Look at the PmxBlog_SSI exmaples ...
Many are stubborn in relation to the path, a few in relation to the target.

Sabrinova

#44
2013 February 24, 07:27:40 pm
Now trying out PortaMX with PMXBlog on my test forum with SMF 2.0.4, I just put the code below into a PHP block, and upon saving it all my forum disappeared except for the side blocks!  In the PHP side block I had created, it gives the error:

QuoteFatal error: Call to undefined function Post_Teaser() in /home/content/**/*******/html/sabrinova/forum/Sources/PortaMx/Class/php.php(62) : eval()'d code on line 55


It's a new forum so I hadn't disabled template eval yet and, as everything I do only shows me a white screen with a theme selector side block plus the above side block, I can't get in my admin panel either.  It's the white screen of death with side blocks  :D  Any ideas?


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


Edit: Your earlier piece of code worked for me though, without the teaser limit.  Now I just need to figure out how to retrieve my test forum so I'll know what to do if I end up doing the same thing to my live site  ;)

Sabrinova

#45
2013 March 03, 01:16:21 pm
Any help with this?  I ended up recreating my test forum from scratch, but this code still produces the same fatal error, even with template evaluation disabled!  I thought I had it cracked when I saw the option in PmxBlog admin to count teaser characters, but no, still the same error.  The first code that displays the entire blog post works fine though, so the problem is somewhere related to the Post_Teaser() function.

feline

#46
2013 March 03, 01:47:38 pm
The function name is changed ...
Replace this line:
Code Select

$article['body'] = Post_Teaser($article['body']); // call the teaser


with:
Code Select

$article['body'] = PmxBlogTeaser($article['body']); // call the teaser

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

Sabrinova

#47
2013 March 03, 02:11:31 pm
Thanks Feline, I just made that change and now I'm getting this:

Fatal error: Call to undefined function PmxBlogTeaser() in /home/content/**/*****/html/******/Sources/PortalBlocks.php(3561) : eval()'d code on line 55

feline

#48
2013 March 03, 02:29:11 pm
Ahh ... yes .. sorry

Modify your blockcode as follow...
Replace:
Code Select

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


with:
Code Select

global $context, $smcFunc, $user_info, $txt, $scripturl, $sourcedir;
include_once('PmxBlogSSI.php');
include_once($sourcedir .'/PmxBlogTeaser.php');
Many are stubborn in relation to the path, a few in relation to the target.

Sabrinova

#49
2013 March 03, 03:05:08 pm
  That did it!  Thank you so much!!!