Detecting Itemid for a component

A little background: while working on the EventList Twitter Status plugin I got frustrated at having to have an Itemid parameter in the plugin parameters. I wanted the script to automatically append the correct Itemid to the URL that gets submitted to Twitter (via TinyURL). However, it seemed that there’s no built-in way to do this using the Joomla API – not when we’re talking about a backend script. If it were a frontend one, we could easily detect the Itemid contextually, i.e. based on which page is being viewed at the time, for example:

JRequest::getVar(‘Itemid‘);

//(detects current page’s Itemid)

Or to detect the URL of a specified menu item:

$menuitem = “34″; //this can be set manually or by your script
$item = JFactory::getApplication()->getMenu()->getItem( $menuitem );
$url = JRoute::_($item->link . ‘&Itemid=’ . $item->id);

However, the above method means that you must already know the Itemid, since the menu id *is* the Itemid. So it’s only good for detecting the URL.

So how do we find out an appropriate Itemid for URLs created on the fly in the backend?

After scouring a lot of posts on the Joomla forum and elsewhere, and also after reading all the available documentation, I got frustrated and just wrote a quick and dirty query:

$queryitemid = “SELECT * FROM #__menu WHERE type=’component’ AND link LIKE ‘%com_eventlist%view=eventlist%’ ORDER BY id ASC LIMIT 1″;
$db->setQuery($queryitemid);
$itemid = $db->loadResult();

if((!itemid) || ($itemid == ”) || ($itemid == NULL)){
//echo “resorting to backup Itemid detection<br>”;
//if default ‘eventlist’ view not found in menu, look for other menu items and use the first one (lowest itemid)

$queryitemid = “SELECT * FROM #__menu WHERE type=’component’ AND link LIKE ‘%com_eventlist%’ ORDER BY id ASC LIMIT 1″;
$db->setQuery($queryitemid);
$itemid = $db->loadResult();

}

if(($itemid != ”) && ($itemid != NULL)){
$itemid = $itemid;
}

else{
//if EventList is now in a menu, use the Itemid set in the plugin parameters.
$itemid = $this->_params->get(‘itemid’);
}

I used a LIKE query to select the “eventlist” view type for the com_eventlist component. I could have avoided use of LIKE by doing a more complex query, and I’m not sure it would have offered much of a performance gain over this LIKE usage. Maybe if this were a script that’s being run a lot, but this only runs when someone adds an event or venue.

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Yahoo! Bookmarks
  • Twitter
No Comments

EventList Twitter plugin v 1.5 out

Update your Twitter status when you add an event to the EventList component. Joomla 1.5 native. Comes with language translation capability and includes English and now also French. You can now add venues as well as events, and have them send a tweet. You can turn off tweets for venues, and you can format the date and time however you want. Download at http://www.plethoradesign.com/downloads/.

  • v. 1.5: added French language definitions
  • v. 1.4: added PHP date() formatting for date & time. Fixed venue addition bug, also allowed for display of venue within event tweet. Removed unused “user layer”.
  • v. 1.3: you can now display the event date and time in your tweet.
Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Yahoo! Bookmarks
  • Twitter
No Comments

Joomla EventList Twitter Plugin – version 1.3

I updated the plugin so you can now choose to display the event date and time. If there is no time specified, it uses just the date. This is *optional* so you can specify it via the plugin parameters, the same place where you put in your Twitter username and password.
http://www.plethoradesign.com/downloads/

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Yahoo! Bookmarks
  • Twitter

Tags:

No Comments

Webcam Test using Flash

I needed to test end users’ webcam video and audio for a client, and found examples of both instant webcam video playback and microphone audio playback (after the user allows access), but no examples combining the two. I put the two together in a single, simple Flash CS3 ActionScript 2 file available here.

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Yahoo! Bookmarks
  • Twitter

Tags:

No Comments

Joomla EventList Twitter plugin v 1.2 out

Some users reported file_get_contents warnings from their server. I modified the plugin to detected whether fopen wrappers are enabled, and if not, use CURL instead. If that’s not available it will simply use your site’s main URL as the event link in your tweet .. otherwise the URL will get cut off by Twitter’s 140 character limit.
Your server doesn’t support the file_get_contents function, but I think I have a solution.

Solution #1 would be to edit your site’s PHP.ini file and set this:
allow_url_fopen = On
It may currently be set to allow_url_fopen = Off, but needs to be on.

See this link for a full description of what to do;
http://www.logaholic.com/support-center/index.php?x=&mod_id=2&id=8
Note that you may need to add this line inside your /httpdocs/php.ini file as well as inside /httpdocs/administrator/php.ini, and you may need to create those php.ini files and FTP them to the server.
On some servers, a PHP.ini file is only allowed in certain locations, like /etc/ or /cgi-bin. But in most cases it should be in the folders I described.
That may fix it.

Solution #2
It means in your case the Twitter links will have to use the actual site URLs rather than TinyURL ones, but it should work.

So, in /plugins/system/eventlisttwitter.php, around line 103, find:

function _createTinyUrl($strURL) {
global $mainframe;
$tinyurl = file_get_contents(“http://tinyurl.com/api-create.php?url=”.$strURL);
return $tinyurl;
}

…. replace that with this:

function _createTinyUrl($strURL) {
global $mainframe;
if(ini_get(‘allow_url_fopen’)){
$tinyurl = file_get_contents(“http://tinyurl.com/api-create.php?url=”.$strURL);
return $tinyurl;
}
elseif(1==3){
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,’http://tinyurl.com/api-create.php?url=’.$strURL);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
else{
return JURI::base();
}
}

If modifying the code is too daunting, uninstall and then reinstall the plugin, using the attached plugin zip file. It’s also on my site at http://www.plethoradesign.com/downloads/.
The above modified code should work for you even without touching php.ini, so it may actually be the easiest solution. If your host doesn’t support PHP’s CURL libraries, the Twitter link will simple link to your site, rather than the individual event. Otherwise the event URL will get cut off because of Twitter’s limit of 140 characters.

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Yahoo! Bookmarks
  • Twitter

Tags:

1 Comment

Essential WordPress Plugins

If you wanted to set up your own site without professional-level web developer help, WordPress is a very nice tool, and has some nice templates available, although you have to be careful not to go overboard installing every plugin under the sun … because then your site could suddenly go blank, and you won’t know how to fix it ;) And then you’ll need technical assistance anyway. This *does* happen, so if you do install WordPress, here are the essential plugins I would recommend; All in One SEO Pack, Google Analytics for WordPress, Google XML Sitemaps, Sociable, WP-SpamFree, WP Super Cache.

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Yahoo! Bookmarks
  • Twitter
No Comments

EventList Venues for Google Earth KML

A Google Earth KML-exporter add-on for EventList 1.0.1 for Joomla 1.5.
It lets you provide visitors a link with which they can directly open or download a KML-format file of all your published venues, complete with venue descriptions, links (if the venue contains one), and automatic creation of markers with latitude and longitude.
That is generated from the basic address information for the venue – you do not need to enter latitude or longitude anywhere. There is just one file to upload, but make sure to read the requirements in the readme.txt file that comes with the zip file.

See it in action here: http://www.novamineralclub.org/calendar. Click on the Google Earth icon at the far right above the calendar.

Download here

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Yahoo! Bookmarks
  • Twitter
1 Comment

Morfeoshow RSS Feed Plugin for Joomla

plg_morfeoshowrss.zip – v. 1.0 – August 22, 2009.

Displays an RSS feed of your latest Morfeoshow images. It’s in ATOM format and you can configure the feed title, description, and number of items. It displays the Morfeoshow thumbnails and links each item to the large version of the image. For Joomla 1.5; tested on 1.5.14.

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Yahoo! Bookmarks
  • Twitter
2 Comments

Let your users have their own calendars!

A Community Builder plugin that can be displayed as a tab on a user’s personal profile, so each user can have a separate calendar. The user just needs to enter the unique ID of the calendar in the plugin parameters in their profile. You can set a default calendar and time zone, and individual users can set their own time zones and calendars as well. This plugin comes with English and Dutch language files. Tested on Joomla 1.5.14 with Community Builder 1.2.1. It should work with or without legacy mode on. Should function in Joomla 1.0 too, though multilingual functionality probably will not work.

Download it here »

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Yahoo! Bookmarks
  • Twitter
No Comments

EventList Twitter Status Update Plugin

I just ported the Twitter Status plugin to make it work with the EventList component. When you add an event, it gets posted to Twitter automatically. Just like the original Twitter Status plugin, you can restrict this to particular categories. Very useful for keeping people informed of upcoming events.

Version 1.0 – July 30, 2009. Joomla 1.5 native only. Comes with language translation capability, but only English is included by default. GPL / open-source.

Download it here

Special thanks to Tomasz Dobrzyński, upon whose Twitter Status plugin this was based.

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Yahoo! Bookmarks
  • Twitter
2 Comments