This blog has moved to a new location! http://iqandreas.github.com/

Monday, June 7, 2010

[K2Fave] Joomla K2Fave - Frequently Asked Questions

This article relates to the Joomla K2 modification "K2Fave"
http://iqandreas.blogspot.com/2010/06/joomla-k2-favorite-item-manager.html


To my surprise and amazement, a lot of responses already and so very quickly. Here are a few questions that have arisen so far. I will keep adding to this list over time, so check back if you run into any issues.


How can I view all my favorites?

There are three ways. Sadly, you are going to need access to the raw PHP code in all instances. If anyone is better with the Joomla framework, perhaps they can help bridge this in a way so you can put in a "favorites" table in any page from inside the "page editor".

Just plain import
You can just plain and simple import a basic page which already has all the imports and everything you need.
include(JPATH_BASE.DS.'components'.DS.'com_k2'.DS.'k2fave'.DS.'viewfaves.html.php');

I noticed one small flaw on that page you might have to fix unless you downloaded the release fixed a few minutes ago. Inside of "viewfaves.html.php"
//Replace the following line
ForetagFave::listUserFavorites($user);

//With this
K2Fave::listUserFavorites($user);

Access the "K2Fave" class directly
Wherever you want the table of favorites to appear, place the following code:
//Get current user - you can do this any way you please
$user =& JFactory::getUser();
K2Fave::listUserFavorites($user);
Access raw data from the database
This might take some PHP experience to get done, but if you want the actual array filled with all favorites, try this code:
include(JPATH_BASE.DS.'components'.DS.'com_k2'.DS.'k2fave'.DS.'k2fave.db.php');
$user =& JFactory::getUser();
$favoritesArray = K2FaveDatabase::getFaves($user->);
The returned array is a list of objects, all with integers named "user_id" and "item_id". See the "K2Fave::listUserFavorites()" function (located in k2fave.php) for an example of how to parse the array into a usable table.

The K2Fave class has a few more functions which may assist in creating a good table; such as makeRemoveURL() and makeK2ItemLink(). See the class definition for more details.


How can I format the favorites table?

The table is formatted as a plain, old <table>, so wrap whatever code you are using to make the table show up in CSS span or div tags, and set whatever formatting you need either in side of those, or in a separate CSS file.

For free tutorials on CSS and how to use it properly, I would recommend W3Schools, along with a good old fashioned Google search.
http://www.w3schools.com/css/default.asp
http://www.google.com/#q=css+tutorial

Otherwise, the table should take on the default formatting for tables set in your global style sheet.


The favorites are able to be added more than once, causing duplicates

This means that the rows were not both set to "PRIMARY_KEY". This can be a bit tricky, and not really common in most cases, but the following guide should help with both creating the table, or modifying the table in case it was already created.

IN PROGRESS: I'm working on a post which describes how to set up the database properly. Should be done tomorrow morning.


I'm getting an error message!

Great! Tell me about it! See the answer to the question below for contact details.

It would be easier if you copy and paste the EXACT error message, which makes it a lot easier for me to track down the bugs.

If a completely blank page is showing up rather than an error, try turning on global error reporting in the Joomla! settings.


But that's not enough! I want my favorites manager to also do this and that, and then do si and so...

Great! I would be happy to implement any ideas you may have into future versions of K2Fave.

If you want very specific modifications made to K2Fave for any part of Joomla or K2, (such as playing a Fanfare when they add an item to favorites, and Taps when they remove the item from favorites - anything really) send me a message using the contact details below.


All this PHP and MySQL is quite confusing. I just want the favorites thing to work; I don't want to worry about it.

I would be more than happy to implement those changes for you, as well as any other reasonable modifications you may want to the existing system for a flat rate of $30 USD. This includes not only installation, but also any text, customization, styling, and custom implementation.

If you have low income or a low traffic site, we might be able to work out special arrangements, so don't give up even if you may be 15 and trying to make it on a $10 per week allowance. ;)


This is fantastic! Your modifications saved me hundreds of dollars! Thank you!

First of all, I would love to hear about your experiences, as well as any live examples of the modification in use. Please leave a comment. :)

Second, I am releasing these modifications for for free, and although it's not required, if you do make money from the project, or have saved money thanks to this project, I would really appreciate a donation so I can keep my programming work alive and keep these modifications and extensions coming for free.
I might even name my firstborn after you out of joy and appreciation.


How can I get ahold of you?

In the README.txt file there is an email address. I would prefer you not release it publicly for fear that it gets picked up by spambots. I hate having to switch to a new email address due to too much spam.

That email address is also used as my MSN Messenger account, in case you prefer instant replies to questions. I'm usually logged in most of the time.

I also have a contact form which will always forward all your messages to the newest email address
http://iqandreas.isbetterthanyou.org/contact.htm

[K2Fave] Joomla! K2 favorites plugin translated and finished

I spent the weekend translating and fixing up the K2Fave modification, so now it should be completely understandable, as well as adjustable to anyone's needs.

For more details, see the original blog post
http://iqandreas.blogspot.com/2010/06/joomla-k2-favorite-item-manager.html


Easily changeable text and user messages

Any major text or language changes can be done in "messages.php", which contains several lines similar to this:
define('T_ADD_TO_FAVES', "Add item to favorites");

Any form of HTML tags, including images, are allowed in that field, so rather than modifying the source directly, all you need to do is modify the text in the messages file. This is also convenient if you want multilingual support for a site, and can easily be achieved with a few slight modifications.


Database changes

If anyone has already implemented the previous release, the database needs to be renamed to "jos_k2_favorites" with the following fields:
user_id int(11) PRIMARY_KEY
item_id int(11) PRIMARY_KEY
NOTE: This is in addition to updating the PHP files!


Documentation

The most relevant information can be found in the README.txt file inside the ZIP, or on the original blog post.

Most everything is self explanatory, but if anyone needs any better documentation or clarification for anything, leave a comment or send an email to the address listed in the readme file.


Installation

The installation steps are the same as before, and the ZIP file can be found in the same location as before.
http://iqandreas.isbetterthanyou.org/files/joomla/k2fave/k2fave.zip


Cheers,
Andreas
http://iqandreas.blogspot.com/
http://iqandreas.isbetterthanyou.org/

Sunday, June 6, 2010

[K2Fave] Joomla! K2 Favorite item manager

NOTE! This modification has been updated to release version 1.0, if you still have the old version (without proper translations), please update. More information is available in this post

Greetings Joomlaers!

As there was a need for a "favorites" option in the Joomla! plugin k2, I have released these modifications. Note that this is not an installable extension. Instead, these are files added to the server, and slight modifications to already existing k2 pages.

I am releasing these modifications for for free, and although it's not required, if you do make money from the project, I would appreciate a donation so I can keep my programming work alive and keep these modifications and extensions coming for free.
These files are released as-is with no guarantee to be free from flaws or completely secure. If you are worried about the code containing security holes, look over the code yourself and make the necessary changes. If you find any vulnerabilities let me know and I will be sure to fix them in the next release.


This is the first release of the project, so any suggestions or tips are VERY welcome.

If you would rather not do all the work of adding the plugin yourself, for $30 USD I will upload and make all changes directly to the server, so you don't have to worry about anything, including any wanted customization such as speical text, CSS formatting, etc. If you have any other "wants" for the project, I can implement those as well.

For further details, leave a comment in the section below, or on my in progress website, or send me an email via the address provided in the README.txt file.


Instuctions for use/installation

Download the ZIP file and extract it temporary location
http://iqandreas.isbetterthanyou.org/files/joomla/k2fave/k2fave.zip

Save the "items.php" file as:
components/com_k2/templates/default/item.php
Note that if you are using an updated version of K2 with a different "item.php" page, copy lines 27-33 into the new "item.php" page, and place them right before the line containing "<!-- K2 Plugins: K2BeforeDisplay -->"

Save the entire folder "k2fave" inside of the folder
components/com_k2/

Finally, create a new table named "jos_k2_favorites", using whatever prefix your Joomla installation currently uses. Your table should be formatted like this:
user_id int(11) PRIMARY_KEY
item_id int(11) PRIMARY_KEY

The easiest way it to open up PHPMyAdmin and add this table manually, however, it is possible to do so via SQL statements instead.


If you have any questions or would like me to do any other Joomla modifications, send me a message.


Cheers,
Andreas
http://iqandreas.blogspot.com/
http://iqandreas.isbetterthanyou.org/

Thursday, June 3, 2010

What is the point of this Blog?

I recently had to write a summary of the blog, and thought it might be a good opportunity to repost this information here and make it clear to all my thoughts and purposes of this Blog.

This blog is a collection of information focused mainly on ActionScript and Flash, with emphasis on game development, plus a little bit extra thrown in. It is aimed to be readable by beginners and not only experienced developers.

Articles are typically in one of the following categories:


The posts also strive to be unique. "If you can find it from 100 different sources on Google, there is no use in reposting what is already out there." Though, I may link to good articles, but I try to avoid writing repetitious information, clogging up the already very filled internet.


If there is any part of ActionScript you want more information on, or have an idea for a good blog post, leave a comment in the section below. A blog isn't much use if the information is irrelevant to it's readers.

Cheers,
Andreas J. Renberg
http://iqandreas.blogspot.com/


And now on to SWF Protection! :)