Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

recipe help for MyBlog

recipe help for MyBlog

Hi,

I am hoping that someone with more PHP skills than I have (would be most developers out there) could help me adapt this recipe to also work with the MyBlog component.

Here is the orginal recipe:

Displaying Module depending on category:

Code:

$category_id = null;

if ( $option == "com_content" ) {
  if ( $view == "category" ) {
   /* category list pages (blog or list style) */
   $category_id = (int)$id;
  } else if (array_key_exists("catid",$_REQUEST)) {
   /* if the category id is in the URL */
   $category_id = (int)JRequest::getInt("catid",0);
  }
  if ( $category_id === null && $view == "article" ) {
   /* if it's an article page without the catid mentioned in the url */
   $nullDate = $db->Quote($db->getNullDate());
   $my_id = $db->getEscaped((int)$id);
   $query = "SELECT  title,  id,  catid "
       . " FROM #__content WHERE id = '$my_id' AND state = 1"
       . " AND ( publish_up = " .  $nullDate
       . " OR publish_up <= CURRENT_TIMESTAMP )"
       . " AND ( publish_down = " . $nullDate
       . " OR publish_down >= CURRENT_TIMESTAMP  )";
   $db->setQuery( $query, 0, 1 );
   $row = $db->loadObject();
   $category_id = $row->catid;
  }
}
/* Now customise any of the following rules for your use.
* $category_id will correspond to the category id of the
* article being displayed (if one is being displayed!)
*/

/* on category 39, return module 69 */
if ($category_id == 39) return 69;
if ($category_id == 40) return 70;
if ($category_id == 41) return 71;

if ($category_id == 44) return 73;
if ($category_id == 45) return 74;
if ($category_id == 46) return 75;

Now - I would like this to ALSO work with the MyBlog component from Azrul ( http://www.azrul.com/products/my-blog.html )

The myblog component output is something like this:

Code:

http://localhost:8888/****/index.php?option=com_myblog&show=mitt-test.html&Itemid=67

for the frontpage of the component. (Itemid is of course the item id of the article.)

Code:


http://localhost:8888/****/index.php?option=com_myblog&task=tag&category=45

for a category page.

I am guessing that it would be fairly easy to just include a few lines of code and have the same sort of functionality for com_myblog as well as for com_content. I just don't know how. Any help is much appreciated!
/anders

Edited By: anders
05-Jan-10 17:53:48

anders
Beginner Modder
ranks
useravatar
Offline
3 Posts
Administrator has disabled public posting

Re: recipe help for MyBlog

Hi Anders, great to hear from you smile

You'd probably get a pretty good recipe using Advanced Debug mode in MetaMod.

Something like:

if ($option == 'com_myblog' and JRequest::getVar('task') == 'tag') {
  $category_id = JRequest::getInt('category',0);
  if ($category_id == 45) return 101; // replace 101 with id of module to insert
}

That at least gets you the category id when you are viewing a "category" page. To get category ids from individual blog post then you'll need to check the URLs and possibly database structure. Do you know if blog posts are stored in their own table, or if they use standard Joomla articles?

Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3313 Posts
User info in posts
Administrator has disabled public posting

Re: recipe help for MyBlog

Second thoughts... I just found an example site using com_myblog, and it looks like the categories are not ID numbers, but names.

http://www.homelessnessinfo.net.au/inde … Itemid=356

So I'd change the recipe above to this:

if ($option == 'com_myblog' and JRequest::getVar('task') == 'tag') {
  $category = JRequest::getVar('category');
  if ($category_id == "45") return 101; // replace 101 with id of module to insert
  if ($category_id == "housing") return 102; // replace 102 with id of module to insert
}

Individual blog posts seem to be named rather than numbered. e.g. .../index.php?option=com_myblog&show=Photos-from-Rachels-Place-in-NYC.html&Itemid=356

That makes it a little more complex to derive the tags from the post, to display modules on an individual "post" page that depend on the tags for the displayed article. It would involve a database lookup against the "show" variable. If you want some help with that I'd need access to the database schema or some code from the component to examine.

Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3313 Posts
User info in posts
Administrator has disabled public posting

Re: recipe help for MyBlog

I'll try to put something together and email it to you.
The site I am working on now only exists on my local machine at the moment, otherwise I would give you all the access you need.
A databasdump and the component package - would that be enough? Or would you rather have me take a backup of the enitre site and send it to you?

Thanks a lot for being willing to help!
/anders

anders
Beginner Modder
ranks
useravatar
Offline
3 Posts
Administrator has disabled public posting

Re: recipe help for MyBlog

Hi Anders,

I've finally put up a set of recipes for MyBlog onto the Recipes page:

http://www.metamodpro.com/support/recip … blog-pages

I trust that at least 1 of these will do what you want!

Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3313 Posts
User info in posts
Administrator has disabled public posting

Re: recipe help for MyBlog

Thanks Stephen!
That's great. Much appreciated!

(It seems there is some junk code in one of the examples though? a couple of <span> tags got in there. . )

And I'll keep working on the translation into Swedish for you.
/anders

anders
Beginner Modder
ranks
useravatar
Offline
3 Posts
Administrator has disabled public posting

Re: recipe help for MyBlog

Oh that's annoying - even JCE editor is a bit touchy about putting in code like this, and wasn't showing me the same as what was showing on the live site :-(

Anyway, fixed now, thanks for letting me know.

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3313 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5913
Dormant:
User Info:
 
Total Users:
10778
Newest User:
negina4qx
Members Online:
0
Guests Online:
146

Online: 
There are no members online

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked