Events - Add a website field

I want to create a section/field in Events that allows for a website URL. So when a member creates/edits a new Event, a section called 'Website' will appear (similar to description), that will allow the member to enter a website URL that supports hyperlinks (clickable - open in a new window).

I know there is no such thing as a 'easy' way of doing it but any assistance would be appreciated. Im pretty sure that the 2 main files to edit will be the BxEventsFormAdd.php and BxEventsFormEdit.php.

 

Note: I already have events on the website, so I cannot uninstall/reinstall to make this happen so if I need to manually run a script, that's no problem.

Nothing to see here
Quote · 17 Jun 2015

I did this with a mod to the groups module

A - add a website field to the Event add form - BxEventsFormAdd.php add this:


                'Website' => array(
                    'type' => 'text',
                    'name' => 'Website',
                    'caption' => _t('_bx_events_caption_website'),
                    'required' => false,
                    'db' => array (
                        'pass' => 'Xss',
                    ),
                ),

Add the Website field to the bx_events_main database table:

ALTERTABLE `bx_events_main` ADD `Website` VARCHAR( 45 ) NOT NULL ;

Then you need to determine where you want to display the url. For this example, I will use the description block.

In BxEventsTemplate.php find:




    function blockDesc (&$aEvent)
    {
        $aVars = array (
            'description' => $aEvent['Description'],
        );
        return $this->parseHtmlByName('block_description', $aVars);
    }


and change to:




    function blockDesc (&$aEvent)
    {
        $aVars = array (
            'description' => $aEvent['Description'],

            'website' => $aEvent['Website'],
        );
        return $this->parseHtmlByName('block_description', $aVars);
    }


in events/templates/base/block_description.html, make like this:

<div class="bx-def-font-large">
        __description__
        <a href="http://__website__" title="__website__" target="_blank">__website__</a>
</div>

 

Lastly, in BxEventsSearchResult.php, add the website field to the search parameters. I usually do this:

'ownFields' => array('ID', 'Title', 'EntryUri', 'Country', 'City', 'Place', 'EventStart', 'EventEnd', 'ResponsibleID', 'PrimPhoto', 'FansCount', 'Rate', 'Description', 'Website'),
        'searchFields' => array('Title', 'Description', 'City', 'Place', 'Tags', 'Categories', 'Website'),

 Create your language key for the Website form field and clear all caches, and that should be it.

website field.png · 377.7K · 172 views
caredesign.net
Quote · 18 Jun 2015

Sorry ProfessorSr. That seems a bit overly complicated. The events module has a few built in things that can be used to make it much simpler.

Here is a more simplified version.

Edit modules\boonex\events\classes\BxEventsFormAdd.php

Look for this.

                'EventEnd' => array(
                    'type' => 'datetime',
                    'name' => 'EventEnd',
                    'caption' => _t('_bx_events_caption_event_end'),
                    'required' => true,
                    'checker' => array (
                        'func' => 'DateTime',
                        'error' => _t ('_bx_events_err_event_end'),
                    ),
                    'db' => array (
                        'pass' => 'DateTime',
                    ),
                    'display' => 'filterDate',
                ),


Add this directly under it.

// Deano Mod Begin
                'Website' => array(
                    'type' => 'text',
                    'name' => 'Website',
                    'caption' => _t('_bx_events_caption_website'),
                    'required' => false,
                    'db' => array (
                        'pass' => 'XssHtml',
                    ),
                    'display' => 'filterWebsite',
                ),
// Deano Mod End


Now edit modules\boonex\events\classes\BxEventsTemplate.php

Just before the closing } at the end of the file, add this code.

// Deano Mod Begin
    function filterWebsite ($i)
    {
        return '<a href="' . $i . '" target="_blank">' . $i . '</a>';
    }
// Deano Mod End

Now add a new language key.

Key Name:  _bx_events_caption_website
Key Text: Website

Now run the following SQL Query in phpMyAdmin

ALTER TABLE `bx_events_main` ADD `Website` VARCHAR( 255 ) AFTER `Tags` ;

Thats it.


https://www.deanbassett.com
Quote · 18 Jun 2015

cool deano - i did not know there was an easier way. I just posted what worked for me. Glad there is an easier way.

 Where should the url display at with your write up?

caredesign.net
Quote · 18 Jun 2015

It displays in the Information block of the Event's main page.

Nothing to see here
Quote · 18 Jun 2015

ok, i thought your original post was that you wanted a block such as description.

caredesign.net
Quote · 18 Jun 2015

That was the original request but anything would work technically. The key was to get it separate. I suggested it's own block because I didn't have any other ideas. I noticed in your screenshot, the URL actually displayed in the description block itself.

 

Of course, All responses are greatly appreciated.

Nothing to see here
Quote · 18 Jun 2015

ProfessorSr,

I've adapted some of your code for my news module. I have an error though: the link cannot be more than about 45 characters. I guess the database entry is not sized right? Do you know how to fix this?

websitefield.png · 36.9K · 157 views
Quote · 22 Jun 2015

in the sql query:

ALTERTABLE `bx_events_main` ADD `Website` VARCHAR( 45 ) NOT NULL ;

this sets the max characters to 45 - change the database field to a higher number (using phpmyadmin)

caredesign.net
Quote · 23 Jun 2015
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.