Invitex Anywhere - How to extend Invitex to work with any content type like Groups, Events, Articles etc.

Version 2.1 Onwards, Invitex integrates a "Invite Anywhere" feature that allows admin to create 'Invite Types' & let users invite for any content element be it Groups, Events, Articles - absolutely anything. Just like a comments system can be extended to any content type, with Invitex Anywhere, we give the ability to Invite for any content type. If you are a developer, you can integrate Invitex anywhere very tightly with your application or any application. Even if you do not know development, we have provided some easy to use Widgets & a flexible module to let non Development users use the Invitex anywhere feature.

We have pre created some Invite Types for you in the ver 2.1 release. You can use these examples to extend Invitex to add your own Invite types. With 2.1 we have Invitations for JomSocial Groups, Events, Joomla Articles precreated.

How to Extend Invitex to a new content type ? Step by step walk through

1. Create  New Invite Type via the Admin interface.

invitex types

When you login to the Invitex Admin, you will see a menu called as Invite Types. This allows you to create a custom Invitex instance for a certain content type. You will see pre created instances for JomSocial Groups & Events & Joomla Articles. Now lets See how this works.

Lets take the example of the Events Invite type we have pre created for you.(Refer Screenshot Below)

Name : Display name of the Invitation Type . When a user tries to send this Invite, we show this Name on the Invitex Window. For Instance ' Invite your Friends to join this Event "
Internal Name : Internal name of the Invitation Type. This is not shown anywhere. This if for internal use only.
Description :  This is explanation show to the user about the Invitation on the frontend below the Invite Name in the Invitex window when this type of a Invite is triggered.
Template HTML : This is the HTML template that shall be used when sending this Invitation type via Email.
Template Text : Customise the text template used for sending this Invite Type
Template Twitter : Customise the Twitter template used for sending this Invite Type. Make sure your message is such that it stays within the 140 character limitation. Remember the Invite url & Name is going to be inserted dynamically. So keep it as short as possible. 
Widget :The Widget will be generated when you save the Invitation type automatically. This field will only show after you save. The widget is the integration code given to you to make it easier for you to Integrate Invites Anywhere in the component of your choice. Note - If you find playing with code complicated, you can use the Invites anywhere module which provides the same functionality. In order to Integrate this in the extension of your choice, we recommend doing a template override & Inserting this code where you want the "Invite" link to show up..
Note that this code contains PHP as well as HTML so make sure you get your PHP tags right.
Catch Action
: We are not currently using this variable. As of now Invites Anywhere does not support Invite tracking. This shall be used when we introduce it. This will be more of a developer feature.

Invite Type Creation

2. A  Embed the Widget in your Template / Extension code via a Template override. (Option I)

In the current example, we have considered using Invitex for inviting people to JomSocial Events. So ideally this link should be placed in a template override for the Event page in JomSocial to replace their regular Invite link OR add it as an additional link. Once you do this, you should get an effect similar to whats shown in the screenshots below.. 

JomSocial Events Page After Override for Code Insertion

invitex ia event example

2.B. use the Easier way - the Invite Anywhere Module.

The Invite Anywhere module is the easier way to show the Invite link on the page you want to use it on without getting your hands dirty with code. However being a module its less flexible & can only be shown in Module positions..

When you go to the backend of "Invite Anywhere" module it will show you following view of  basic and advanced parameters:

Invitex ia mod basic

invitex ia mod ad

Basically parameters of "Invite anywhere" are the variables those are used to create the "Invite Anywhere" url..

The basic parameters are:

Open Invitex In:This parameter gives you option to open the "Invite Anywhere" in light box,or in parent window or in another window...

Invite Type:This field allows you to select one of the Invitation types  you have created in Admin.

Invite Anywhere Button Text: The text which you will write in this parameter will be shown as a text on button in frond end of "Invite Anywhere" module..By default it is set to "Invite"

The Advanced parameters are:

Invite URL:If you want to pass a different Invite Url other than the page the user is currently on, you can use this variable to pass it. The url needs to be encoded before passing it using the urlencode fucntion in PHP.

Custom code: This part is the code that you need to write in order to determine the name of the element that the Invite is being sent for. This code will be like the code shown in the Widget explanation except without the html show shows the link.

Catch Action : We are not currently using this variable. As of now Invites Anywhere does not support Invite tracking. This shall be used when we introduce it. This will be more of a developer feature.

Note : If Invite URL is not set, and suppose Invite Anywhere module is published on a Event page , form where Invitations are sent to join that Event, the 'Join' url that user get in the Invitation will be the URL of this event page from where Invitations are sent.

Continuing  our example ,If you want to "Invite your friend to join an event" you have to follow following steps in the module :

1. Set the "Invite type" shown in basic parameter of module to "Invite your friend to join an event"..

2. Publish and save the module to appear on the JomSocial Event Pages only . Advanced Module manager can help you achieve this.

Invites Anywhere Popup - Customised for Events

Invitex Anywhere Popup - Events

3. Advanced - For Developers / Advanced Users

With Invites anywhere, we have made a very tight integration with any application possible. This might not be too straight forward for novice users. Lets look at the Widget code now & how you can customise it..

$name="";
//Get the Event Id from the URL
$eid=JRequest::getVar("eventid");
//Fire the query to translate the url to the name from the db table
$db =& JFactory::getDBO();
$db->setQuery("SELECT title FROM #__community_events WHERE id=$eid");
						$name=$db->loadResult();
//Note that $name should always return a string
$link="index.php?option=com_invitex&view=invites&tmpl=component&catch_act=&invite_type=2&invite_anywhere=1&tag=[name=".$name."]";
JHTML::_("behavior.modal", "a.modal");?>Invite Anywhere

Above you will see that we have added comments in the appropriate places to explain how the code is constructed. Now let us look at what are the variables you can pass to the Invite anywhere url.
$invite_type - This is the Id of the Invite type you have created in the admin.
$catch_action - Not being used right now
$invite_url - If you want to pass a different Invite Url other than the page the user is currently on, you can use this variable to pass it. The url needs to be encoded before passing it using the urlencode fucntion in PHP.
tag - This is used to pass custom variables you want to pass to Invitex to further customise either the Invitex Popup or the Invitex email. Currently we are only supporting the name tag to be passed as tag=[name=".$name."]" . But for a developer it will be straight forward to pass more information like this & use it as needed.


**** Note that if you want help in creating new Invite Types of a advanced Nature, they can developed for you by us at an extra cost. Since this is a bit complicated & novice users might have very entry level questions - its not possible to cover this under standard support scope & falls under Customizations. If you have issues with existing pre-implemented invite types, they are covered under regular support subscriptions.