Home Private Messages Search
CPG Dragonfly™ CMS stopsoftwarepatents.eu petition banner
Toggle Content
 
Forums ⇒ DragonflyCMS ⇒ Add-Ons & Blocks ⇒ Some jQuery functionality for DF modules


Some jQuery functionality for DF modules
Need help creating a block or add-on, or you have created or modified a block/add-on that works in Dragonfly CMS and it meets the CPG Security Requirements? Do you have feedback about a specific add-on? Here is the place to post. Read the announcements here first!.
Go to page Previous  1, 2
Post new topic    Reply to topic    Printer Friendly Page     Forum Index ⇒  Add-Ons & Blocks

View previous topic :: View next topic  
Author Message
greenday2k
Forum Admin
Forum Admin

Offline Offline
Joined: Aug 11, 2005
Posts: 489
Location: CO
PostPosted: Wed Jul 14, 2010 8:10 pm
Post subject: Re: Some jQuery functionality for DF modules

Whoa, this class is awesome, it will be so easy to implement many cool features on DF sites.

As user of your comment "plugin" is this module compatible with it? Do i have to copy the old entries to a new table? or just plug & play?

_________________
www.greenday2k.net


greenday2k's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Back to top
View user's profile Visit poster's website MSN Messenger Yahoo Messenger
Kendle
500+ Posts Club
500+ Posts Club

Offline Offline
Joined: Dec 16, 2004
Posts: 552

PostPosted: Wed Jul 14, 2010 8:24 pm
Post subject: Re: Some jQuery functionality for DF modules

greenday2k wrote:
As user of your comment "plugin" is this module compatible with it? Do i have to copy the old entries to a new table? or just plug & play?

It uses the same table but how you use it is different. You'll need to update your module(s) to use the new method.

In your old module you would have :-

PHP:

$var
= new comment(blah, blah);

Now it would be :-

PHP:

$jQ
->cmmt_link(blah, blah);
$jQ->cmmt_display();

Just don't forget to put :-

PHP:

$jQ
= new jquery();
$jQ->cmmt();
$jQ->header();

somewhere in your code before header.php is included.

(tbh I'm stunned anyone uses the old plug-in!)

edit : I notice you use my Movie module. That module has some Protoype scripts and some hand made scripts and is a bit messy. I'm going to re-write all that with jQuery, next up being a "rating" plug-in and a "favourites" plug-in.

Although I'm a bit in 2 minds how to implement it. The class is getting a bit big and it'd be sensible to split it into sub-classes that extend the jquery class, but that would only really work in an elegant fashion if the jquery core files were included in DF natively (i.e. add them to header.html at the very least or cmsinit.inc), but obviously I'd rather not do that.

( if only DF used a javascript framework ... )

_________________
Gaming League / Cup - www.leaguecms.co.uk :: Other DragonFly modules - www.cmsdreams.co.uk

Kendle's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Back to top
View user's profile Visit poster's website
layingback
Forum Admin
Forum Admin

Offline Offline
Joined: Apr 19, 2004
Posts: 1040

PostPosted: Wed Jul 14, 2010 9:23 pm
Post subject: Re: Some jQuery functionality for DF modules

Kendle wrote:
(tbh I'm stunned anyone uses the old plug-in!)

Laughing I was planning to ... The hooks have been left in Pro_News to add it in. Just never got that far down the to-do list.


Kendle wrote:
... but that would only really work in an elegant fashion if the jquery core files were included in DF natively (i.e. add them to header.html at the very least or cmsinit.inc), but obviously I'd rather not do that.

( if only DF used a javascript framework ... )

Maybe I'm missing something, but can't you just add 1 line "require_once your_jQ_stuff.inc" or similar to cmsinit.inc, that would be easy to maintain across releases?

_________________
Pro_News: The complete module for Dragonfly - now available as version 3.3

layingback's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
2.6 - 3.6 / 1.3.42 - 2.2.12 / 5.0.92 - 5.1.37 - 5.1.54 / 4.4.49 - 5.2.17 - 5.3 / 9.2.1
Back to top
View user's profile Visit poster's website Photo Gallery
Eestlane
I18N / L10N Lead Dev
I18N / L10N Lead Dev

Offline Offline
Joined: Apr 06, 2005
Posts: 1404
Location: Estonia
PostPosted: Wed Jul 14, 2010 10:06 pm
Post subject: Re: Some jQuery functionality for DF modules

You can include javascript and css files through adding to global $modheader variable in case you didn't know it.


Eestlane's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Linux/2.0.63/5.0.67/5.2.8/9.2.1
Back to top
View user's profile Send e-mail Visit poster's website
greenday2k
Forum Admin
Forum Admin

Offline Offline
Joined: Aug 11, 2005
Posts: 489
Location: CO
PostPosted: Wed Jul 14, 2010 10:39 pm
Post subject: Re: Some jQuery functionality for DF modules

Yes, i use the mclip and the comment plugin (early versions), i'll update updates versions soon. And yes thanks, useful modules.

The ajax rating and Add fav's functions will be great.

Quote::
You can include javascript and css files through adding to global $modheader variable in case you didn't know it.

I wish an official $modfooter var to add all scripts on the end of the body tag ;D

_________________
www.greenday2k.net


greenday2k's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Back to top
View user's profile Visit poster's website MSN Messenger Yahoo Messenger
earth
Heavy poster
Heavy poster

Offline Offline
Joined: Mar 01, 2006
Posts: 268

PostPosted: Thu Jul 15, 2010 1:37 am
Post subject: Re: Some jQuery functionality for DF modules

kendle sent ya pm on what a search member jQuery entail, as been toying with it and know you done bought the books and paid the tuition for me, just thought a little more schooling be nice on how to get this implemented in more places!

tab or tooltip


...is this what ya talking about when it comes to a cms with framework

modxcms.com/

Quote::
We don't think you should have to buy a book to build amazing sites that look and behave exactly how you want. And we mean exactly, with no forced columns, blocks or zones to hack up. Just total, complete, unadulterated creative freedom … the way it should be.
PHP Content Management Framework
PHP Application Framework
MODx is an open source PHP Content Management Framework that helps you take control of your online content.

It empowers developers to build those ever-demanded "Web 2.0" sites and custom applications today—you know, because that's what your clients want. And if you're a CSS designer or Ajax aficionado, this is the CMS for you; Like what you see today? You'll love what's coming.

MODx enables developers and advanced users to give as much control as desired to whomever they desire for day-to-day website content maintenance chores. It makes child's play of building content managed sites with validating, accessible CSS layouts using any Ajax library or techniques you wish, hence why we refer to it as an Ajax CMS. Heck, it even plays well with and can be used as a Flash CMS.

Techies call MODx a Content Management Framework ("CMF"): equal parts custom web app builder and Content Management System ("CMS"). With a flexible API and a robust event override system, MODx makes building engaging web projects straightforward — or changing core functionality without hacking the core code possible. Custom tweaks won't leave you pulling out your hair when it's time to upgrade.

Not only does MODx help you build sites quickly, but it also is both robust and simple. As far as end-users know, MODx is just an easy-to-use online application; for developers there's freely available resources and a fantastic end-user community.

MODx is the alternative to hacking blogging apps and other tools to death, extended learning curves, and changing your workflow to fit software that just doesn't quite "get it". MODx also doesn't make you reinvent solutions to problems that have been solved many times over: basic content management tasks, login and permissions, Ajax communications, JSON handling, i18n/l10n, and the myriad of other items common across typical online applications. MODx allows you to focus on usability, design, business logic, content and building great sites, not on the tools that build them.

_________________
dfaddons.com

earth's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
OS/Apache/Mysql/php/9.2.X/
Back to top
View user's profile Visit poster's website Photo Gallery
layingback
Forum Admin
Forum Admin

Offline Offline
Joined: Apr 19, 2004
Posts: 1040

PostPosted: Thu Jul 15, 2010 6:59 am
Post subject: Re: Some jQuery functionality for DF modules

Or if you don't want to make any change to DF Core at all (not even the call in footer.html as Phoenix does with Storez), then I think you could install as a module and add a block near the bottom/right, which would have something like this for its code
Code::
if (!defined('CPG_NUKE')) { exit; }
global $MAIN_CFG;
$gblsettings = $MAIN_CFG['global'];
get_lang('Your_Module_Name');
if (is_active('Your_Module_Name')) {
	require_once('modules/Your_Module_Name/functions.php');
	$content = 'ERROR';
} else {
$content = _YMN_NOTACTV;		// Not Active Message
}

The ERROR setting of $content ensures no output from the block and no "Bad Block" warning. If you packaged your jQuery class as a module ("Your_Module_Name") which included this Block, then you'd have a zero-impact install on DF Core Code package which did place the javascript almost at the end of the page. And by selectively assigning this Block to be active only for modules using jQ you keep any overhead to a minimum.

(You can install Blocks programmatically as well.)

_________________
Pro_News: The complete module for Dragonfly - now available as version 3.3

layingback's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
2.6 - 3.6 / 1.3.42 - 2.2.12 / 5.0.92 - 5.1.37 - 5.1.54 / 4.4.49 - 5.2.17 - 5.3 / 9.2.1
Back to top
View user's profile Visit poster's website Photo Gallery
Kendle
500+ Posts Club
500+ Posts Club

Offline Offline
Joined: Dec 16, 2004
Posts: 552

PostPosted: Thu Jul 15, 2010 7:15 am
Post subject: Re: Some jQuery functionality for DF modules

Eestlane wrote:
You can include javascript and css files through adding to global $modheader variable in case you didn't know it.

Which is exactly what this class does Wink

@layingback, I could of course add a single line to any appropriate core file to include a bunch of stuff elsewhere, but I'd rather not, and adding something to the footer isn't the right way to do it either, the jquery core files and CSS need to go in the header, so if it's going to be added anywhere it'd be in cmsinit.inc / header.php / header.html.

I haven't got a problem with doing it this way for now, it would only be an issue if there were several modules / plug-in classes like this that were all using jQuery, you need to check that the files you want to use aren't already included elsewhere before attempting to include them again.

It would of course help enormously if there were additional global variables for adding stuff to the header, perhaps :-

$mod_css - an array containing a list of stylesheets
$mod_lib - an array containing a list of javascript libraries
$mod_script - a string containing custom javascript

You could test these variables to see if what you want to include is already included (or header.php could check them for duplicates).

_________________
Gaming League / Cup - www.leaguecms.co.uk :: Other DragonFly modules - www.cmsdreams.co.uk

Kendle's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Back to top
View user's profile Visit poster's website
layingback
Forum Admin
Forum Admin

Offline Offline
Joined: Apr 19, 2004
Posts: 1040

PostPosted: Thu Jul 15, 2010 9:15 pm
Post subject: Re: Some jQuery functionality for DF modules

Kendle wrote:
It would of course help enormously if there were additional global variables for adding stuff to the header, perhaps :-

$mod_css - an array containing a list of stylesheets
$mod_lib - an array containing a list of javascript libraries
$mod_script - a string containing custom javascript

You could test these variables to see if what you want to include is already included (or header.php could check them for duplicates).

Then do that. I mean rather than just do the 1 line for 1 module now, put the calls in one time for each of the above, and everyone else can cantilever off of that.

Then we only have 1 patch to Core to maintain. Just a thought ...

_________________
Pro_News: The complete module for Dragonfly - now available as version 3.3

layingback's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
2.6 - 3.6 / 1.3.42 - 2.2.12 / 5.0.92 - 5.1.37 - 5.1.54 / 4.4.49 - 5.2.17 - 5.3 / 9.2.1
Back to top
View user's profile Visit poster's website Photo Gallery
Kendle
500+ Posts Club
500+ Posts Club

Offline Offline
Joined: Dec 16, 2004
Posts: 552

PostPosted: Tue Jul 20, 2010 2:39 pm
Post subject: Re: Some jQuery functionality for DF modules

layingback wrote:
Then do that....

OK. Very Happy

Attached is the latest version, with a few key amendments.

I've split the classes into separate files so if you only want one of the features you only need include the appropriate file. So, to use AJAX comments for example, you would include CORE_PATH.'classes/jcmmt.php' and declare an instance with $var = new jcmmt();.

There's no need for $jQ->header() as the class(es) now all use additional global variables I've added to cmsinit.inc (modified version included in the package).

In fact I've modified 3 core files :-

includes/cmsinit.inc
header.php
footer.php

I've declared several new global variables as follows :-

$modlib

An array containing a list of additonal javascript libraries to be added to the [head] section of the website.

Note: you only need specify a library name, not the path to it, as it's assumed all libraries are in includes/javascript/jquery/, so if a file is included like so :-

PHP:

$modlib
[] = 'mylibrary.js';

it would become :-

includes/javascript/jquery/mylibrary.js


$modcss

An array containing a list of stylesheets to be added to the [head] section of the website. For example :-

PHP:

$modcss
[] = 'mystylesheet.css';

Note: Stylesheets for jQuery scripts should go in themes/THEMENAME/ rather than themes/THEMENAME/style/ because jQuery's own CSS framework (included) uses image references of the form url(images/image.png) rather than url(../images/image.png). The code assumes this.

$modscript

A string containing javascript code to be added to the [head] section of the website. Any code added to this variable will be wrapped in the appropriate code to execute it on DOM ready, like so :-

Code::
[script type="text/javascript"]
$(function() {
  // $modscript goes here
});
[/script]

$modfooter

A string the contents of which will be added to the bottom of the HTML after the page footer (credits etc.), useful for hidden elements used in scripts and / or scripts that need to go in [body] rather than [head].




The jQuery classes themselves have been split into separate classes (all of which extend the jQuery class). The files are :-

Comments

In your module include this file and declare an instance of the class :-

PHP:

require_once(CORE_PATH.'classes/jcmmt.php');
$jcmmt = new jcmmt( array('KEY' => $VALUE) );

Parameters are passed as an array of key => value pairs, like so :-

PHP:

$jcmmt
= new jcmmt(array(
'CMMT_QUOTE' => true,
'CMMT_REPLY' => true,
'CMMT_SPACER' => 3,
'CMMT_MAXNEST' => 20
));

To add a comment box to your module you must first create a link to your module like so :-

PHP:

$jcmmt
->link($mod, $link, $page, $key1, $key2);

To then display a comment box in your module :-

PHP:

$jcmmt
->display();

To delete all comments associated with the linked module record

PHP:

$jcmmt
->delete();

To count comments associated with the linked module record

PHP:

$jcmmt
->count();

To retrieve the total comments associated with the linked module

PHP:

$jcmmt
->total();

Date Time Picker

In your module include this file and declare an instance of the class :-

PHP:

require_once(CORE_PATH.'classes/jdate.php');
$jdate = new jdate(true, true, true, 15);

Note: You must do this before including "header.php" in your code.

To add a date / time picker to your form :-

PHP:

$jdate
->field($fieldname, $value);

To retrieve the date entered by the user :-

PHP:

$jdate
->input($fieldname);

There are some additional functions provided :-

PHP:

$jdate
->current();

returns the current GMT date / time (same as gmtime() if you're using timestamps)

PHP:

$jdate
->toLocal($gmtdatetime);

converts a GMT date/time to the user's local timezone

PHP:

$jdate
->toGMT($localdatetime);

converts a date in the user's local timezone to GMT

PHP:

$jdate
->display($datetime, $format);

displays a GMT date / time to the user in their local timezone, and formats it according to $format if suppplied (or the date format specified in their website account if not)

Tabs

In your module include this file and declare an instance of the class :-

PHP:

require_once(CORE_PATH.'classes/jtabs.php');
$jtabs = new jtabs($tabname, $selected);

Note: You must do this before including "header.php" in your code.

To add a tab :-

PHP:

$jtabs
->add($id, $label, $url);

To display the tabs once they've all been specified :-

PHP:

$jtabs
->display();

Text Editor

In your module include this file and declare an instance of the class :-

PHP:

require_once(CORE_PATH.'classes/jtext.php');
$jtext = new jtext($html, $toolbar, $skin);

Note: You must do this before including "header.php" in your code.

To add an editor to a form :-

PHP:

$jtext
->field($id, $text, $form, $cols, $rows);

To display text :-

PHP:

$jtext
->display($text);

Tooltips

In your module include this file and declare an instance of the class :-

PHP:

require_once(CORE_PATH.'classes/jtips.php');
$jtips = new jtips($width);

Note: You must do this before including "header.php" in your code.

To add a tooltip :-

PHP:

$jtips
->display($title, $url, $label);

Note: functions have been renamed for clarity and consistency compared to the previous version (not that I expect anyone has done much with this so far).

edit: Can't attach the package, it's too big, so please download it here :-

www.cmsdreams.co.uk/in...s&id=7

_________________
Gaming League / Cup - www.leaguecms.co.uk :: Other DragonFly modules - www.cmsdreams.co.uk

Kendle's server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS)
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic    Reply to topic    Printer Friendly Page    Forum Index ⇒  Add-Ons & Blocks
Page 2 of 2
All times are GMT
Go to page Previous  1, 2



Jump to:  


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


 
   Toggle Content User Info

Welcome Anonymous

Nickname
Password
(Register)

   Toggle Content Last CVS commits
· Fixed .ico Expires header.
· Removed domain name from cookies so subdomains wont access them anymore.
· CSS and JS, case insensitives.
· CSS and JS, send correct HTTP 1.1 headers and fixed issues where themes and...
· Further security class improvements.
· 301 redirects on LEO changes
· Option to force 3xx http status codes
· Validate googlebot.com and google.com crawlers.
· CCBot
· Rss with etag and atom.

pročitaj još...

   Toggle Content Community

Support for DragonflyCMS in a other languages:

Deutsch
Español

   Toggle Content X-links
UltraEdit Browse Happy logo Firefox MySQL PostgreSQL Valid CSS! Valid XHTML 1.0! Unicode Encoded Badge NukeBiz Resources Raven DragonflyCMS Dedicated Now InsideSupport Lampe Berger

You are seeing squares or questionmarks on this page?

All content of this website is copyrighted by the Creative Commons NC-SA
The logos and trademarks used on this site are the property of their respective owners
We are not responsible for comments posted by our users, as they are the property of the poster.
Our server runs on a P3 1.2GHz with 512MB RAM with no accelerators
Support GoPHP5.org
Interactive software released under GNU GPL, Code Credits, Privacy Policy