AdvancedContent

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.

What do you think: Use the image uploads dir or just the uploads dir for {content_image}?

image uploads dir
23
68%
uploads dir
8
24%
don't care
3
9%
 
Total votes: 34

gabriel.rota

Re: AdvancedContent

Post by gabriel.rota »

Hello everyone,
I have a question ... this module don't provides the use of multiple checkboxes ?
I see only sample with multiselect but not the same thing with checkbox.
Perhaps I can be of help if placed on the right track :D
NaN

Re: AdvancedContent

Post by NaN »

Hello Gabriel and welcome to the forum.

Sorry, i don't get it.
If you want multiple checkboxes just put multiple checkboxes in your template:

Code: Select all


{content block="A" block_type="checkbox"}
{content block="B" block_type="checkbox"}
{content block="C" block_type="checkbox"}


One single checkbox is nothing else but one selectable item.
You can turn it on and off.
If checked it stores 1 in the db.
If not it stores 0.

A multiselect list with only one item and value 1 would behave the same way like a checkbox.
You can select and deselect it.
If selected it will store the assigned value (e.g. 1).
If not it stores an empty value.

I know 1 and 0 is not the same like 1 and ''.
But it will result in the same if you check the value in the template like this:

Code: Select all


{* single checkbox: *}
{content block="single checkbox" block_type="checkbox" assign="checkme"}
{if $checkme}
   ... do something ...
{/if}

{* select multiple with only one item and value 1 *}
{content block="single item" block_type="select_multiple" items="one single item" values="1" assign="checkme"}
{if $checkme}
   ... do something ...
{/if}

You see what i mean?

In the module the value of a checkbox is always 1 or 0. You cannot assign a custom value to a checkbox. It does not make sense to me to create a contentblock to toggle something on/off but use a specific value for it because it can only be checked or not (1 or 0):

Code: Select all


{* does not make sense to me: *}
{content block="show sidebar" block_type="checkbox" value="halligalli" assign="show_sidebar"}
{if $show_sidebar == 'halligalli'}
   ... some stuff here ...
{/if}

You have the name of the option and you just want to check if it is set or not.
So you don't need a custom value for this checkbox.
This would do the same but makes more sense to me:

Code: Select all


{* does make more sense to me: *}
{content block="show sidebar" block_type="checkbox" assign="show_sidebar"}
{if $show_sidebar}
   ... some stuff here ...
{/if}

That is why you cannot assign custom values to checkboxes.
There simply is no need for it (IMO).

If there would be one block with multiple checkboxes you would also need to assign custom values to the checkboxes to know what has been selected. Otherwise it would just store Zeros and Ones and you would always need to remember the exact sequence of the items to check wich one has been set or not.

And a block of multiple checkboxes with labels and values would result in exactly the same like a multiselect list. Just compare the code:

Code: Select all


{* Multiple checkboxes *}
{content block="multiple checkboxes" block_type="multiple_checkboxes" items="select 1,select 2,select 3,..." values="1,2,3,..." delimiter=","}

{* Multiselect list *}
{content block="multiselect list" block_type="select_multiple" items="select 1,select 2,select 3,..." values="1,2,3,..." delimiter=","}

Multiple checkboxes are nothing else like multiple selectable items.
Technically there is no difference between activating one or more checkboxes and storing them in one contentblock or selecting one or more items of a multiselect list and storing them the same way.

And this is why the module does not provide all kind of input fields because some input types just look different but in fact they do the same. It doesn't matter if you have a group of checkboxes or a select list with multiple selectable items. So we don't need to waste memory and put in the same code twice.
(There also are no radio buttons because this can also be realised by a simple dropdown.)

So if you don't want to have single checkboxes but a group of selectable items that are stored in one contentblock (separated by delimiter) just use the select multiple bocktype. It will result in exactly the same like multiple checkboxes.

If you use the select_multiple blocktype with sortable_items=true you will have the same items but shown as checkboxes that can be reordered. But it is stored in the same way like the multiselect stuff.
So you see, there really is no (technical) difference between multi checkboxes and multiselect.
(I just use checkboxes when sortable_items is true because it is easier to create a table with sortable rows than a multiselect list with sortable items)
Last edited by NaN on Sat Sep 04, 2010 6:19 pm, edited 1 time in total.
NaN

Re: AdvancedContent

Post by NaN »

Here you can downoad the latest RC of version 0.5

Any help in testing this would be apreciated.
If no errors are reported i will release the official version in forge next week.

Notice: against the votes here in the poll i decided to use only the uploads dir for files and images. This wil provide best compatibility and flexibility at the moment.

I added a switch that checks if the {content_image} tag or the {AdvancedContent block_type="image"} tag is used. If the {content_image} tag is used the file will be stored like in the default content type (uploads/...).
If the {AdvancedContent} tag is used it stores the path without the uploads dir.

Same in frontend: if the {AdvancedContent} tag is used but the page is of type content it uses the stored value as source of the image.
If the page is of type AdvancedContent it will prepend the uploads dir to the stored value.

The downside is that you 1st need to update your templates and adjust the image path of the param dir of blocktypes image. 2nd you need to update all pages that are of type AdvancedContent since the image dir missed there.

Please also read the changelogs and release notes.
Last edited by NaN on Sat Sep 04, 2010 6:13 pm, edited 1 time in total.
gabriel.rota

Re: AdvancedContent

Post by gabriel.rota »

NaN wrote:
Hello Gabriel and welcome to the forum.
Thanks!

If you use the select_multiple blocktype with sortable_items=true you will have the same items but shown as checkboxes that can be reordered. But it is stored in the same way like the multiselect stuff.
So you see, there really is no (technical) difference between multi checkboxes and multiselect.
(I just use checkboxes when sortable_items is true because it is easier to create a table with sortable rows than a multiselect list with sortable items)
Thanks for clear explanation.
My problem isn't technical but of look.
This is the solution to my cryptic question :)

Code: Select all


{* Multiselect list checkbox look*}
{content block="multiselect list" block_type="select_multiple" items="select 1,select 2,select 3,..." values="1,2,3,..." delimiter="," sortable_items=true}

Is possible have the checkbox on multiple columns for limit space wastage?
NaN

Re: AdvancedContent

Post by NaN »

gabriel.rota wrote:
My problem isn't technical but of look.
Well... the modules purpose is not to look good but just to provide functionality ;)
But at the moment i think of a new block type anyway. Maybe a kind of "block group" that may allow to create content blocks that consists of several (even different) controls. So a simple multi checkbox block would also be possible.
We'll see ;)
gabriel.rota wrote:
Is possible have the checkbox on multiple columns for limit space wastage?
Not at this time.
Maybe this can be realised by additional params (like cols/rows) but as i said, the module is not just to look good in backend (anyway this would cause a rewrite of the sortable function since it only sorts the table rows not the cells). But i think of using templates for the "block groups" that can be customized by the backend user. So you can create the output of content blocks by yourself. But this will take a while so just be patient and stay tuned ;)
NaN

Re: AdvancedContent

Post by NaN »

One important notice to all those that use the SVN version:
Do not check out the trunk dir at the moment.
Use the dir tags/0.5.+ instead.
The trunk dir is for 0.6 and will not work properly at the moment.
NaN

Re: AdvancedContent

Post by NaN »

NikNak wrote:
Fatal error: Call to a member function GetModuleInstance() on a non-object in /modules/AdvancedContent/contenttype.Content2.php on line 481

...

In the page list where it should say 'advanced content' as the page type it says:
ModuleName() not defined properly

...

I have restored an old database and I can now edit pages again - but am curious to know what went wrong here?
I recently also run into this somewhat old problem.
But i know how to fix it now.
The reason for that error was that i had an error in the upgrade script.
The module indicated to be version B but installed was version A.
The upgrade script did not update the version info properly.
So in the db there was another version info stored than the module returned.
This will cause this error.

If anyone ever runs in this problem again (even if it is another module) here a quick and easy solution:

Take a look into the AdvancedContent.module.php and look for a function called GetVersion(). Compare the version there with the one that is stored in your db. (table modules). Change the value of the db version info to that of the module file.

This will fix the problem.
User avatar
NikNak
Forum Members
Forum Members
Posts: 183
Joined: Fri Oct 02, 2009 2:28 pm

Re: AdvancedContent

Post by NikNak »

Hi NaN

Funnily enough this (issue as above) has happened again today - but without me updating the script at all! V weird.  [EDIT: just fixed it using the above instructions]

But another issue occurred today:
In the Advanced Content tab, there is the 'Use Expire Date' function.
If I use this as an 'admin' and set the dates, all works fine - but while the 'Use Expire Date' is set, if an 'editor' tries to update the page, there is an error "End date must be later than start date."

It wouldn't be a problem, but I have needed to set a few pages to become live while Im on holiday. With this problem it means that the 'editor' cannot change any of the content on any of these pages.

Any help? (I think I will have to get the pages activated manually instead).

Thanks

Nik
Last edited by NikNak on Tue Sep 14, 2010 5:24 pm, edited 1 time in total.
NaN

Re: AdvancedContent

Post by NaN »

Does the editor have the permission to manage AdvancedContent options?
This permission comes with 0.5 and might be needed for required or validated options.
I guess it checks for the date regardless if it can be set or not.

EDIT:

Confirmed.
If user has no permission to edit the AdvancedContent options he cannot change pages where start/end date has been set.

I just committed a fix to SVN (path tags/0.5.+).

If you cannot check out SVN this may fix it:

in line 260 of contenttype.Content2.php it says:

Code: Select all


if ($this->GetPropertyValue('use_expire_date') == '1' && $this->GetPropertyValue('end_date') <= $this->GetPropertyValue('start_date')) {

change this to:

Code: Select all


if ( check_permission(get_userid(), 'Manage AdvancedContent Options') && $this->GetPropertyValue('use_expire_date') == '1' && $this->GetPropertyValue('end_date') <= $this->GetPropertyValue('start_date')) {

So it only validates the start/end date input if user has permission to edit it.

Also in line 97 of inc/function.fillParams.inc.php it says:

Code: Select all


if(($oneparam == 'start_date' || $oneparam == 'end_date')) {

change this to:

Code: Select all


if(($oneparam == 'start_date' || $oneparam == 'end_date') && check_permission(get_userid(), 'Manage AdvancedContent Options')) {

And same file line 108 change this:

Code: Select all


if(isset($params['start_date']) && isset($params['use_expire_date']) && $params['use_expire_date'] == 1 && $params['start_date'] > time()) {

to this:

Code: Select all


if(check_permission(get_userid(), 'Manage AdvancedContent Options') && isset($params['start_date']) && isset($params['use_expire_date']) && $params['use_expire_date'] == 1 && $params['start_date'] > time()) {

I'm not sure if the changes to the fillParams.inc.php are really needed but just in case.
Last edited by NaN on Wed Sep 15, 2010 4:33 am, edited 1 time in total.
User avatar
NikNak
Forum Members
Forum Members
Posts: 183
Joined: Fri Oct 02, 2009 2:28 pm

Re: AdvancedContent

Post by NikNak »

Thanks for the code alterations.  :-)

The start date and end date were set correctly - so should have passed the check regardless. Whatever dates I entered as an admin, I got the error as an editor.

Kind regards

Nik
User avatar
NikNak
Forum Members
Forum Members
Posts: 183
Joined: Fri Oct 02, 2009 2:28 pm

Re: AdvancedContent

Post by NikNak »

Hi NaN

One thing that I had achieved in earlier versions of Content2 was getting a value of "" (ie nothing) from a dropdown list.

I used this to select a class for a div:
{content block="modifier"  block_type="dropdown" items="Please select|Standard|Narrow" values="|std|sml"}

But now with an up to date version of Content2 my div class has become "please select".

Is there a way to achieve the same result as before without resorting to smarty tricks to change the result.

Kind regards
Nik

EDIT: regarding your poll about the directory for content_image - I can see me wanting to use this to select things like pdf's - which I would probably put in the uploads folder by default rather than uploads/images. Having it as 'uploads' gives more flexibility. (perhaps there are other arguments that could persuade me otherwise).
Last edited by NikNak on Wed Sep 15, 2010 1:25 pm, edited 1 time in total.
NaN

Re: AdvancedContent

Post by NaN »

Yes you're right.
It strips off empty values/items.
This is already fixed in SVN.

To fix it yourself change the following lines in the file inc/function.displayContentBlocks.inc.php (just remove the function $this->CleanArray( ... ) that wraps the explode function):

Code: Select all


foreach($this->CleanArray(explode($blockInfo['delimiter'], $blockInfo['items'])) as $key => $val) {

Code: Select all


foreach(explode($blockInfo['delimiter'], $blockInfo['items']) as $key => $val) {

Code: Select all


foreach($this->CleanArray(explode($blockInfo['delimiter'], $blockInfo['values'])) as $key => $val) {

Code: Select all


foreach(explode($blockInfo['delimiter'], $blockInfo['values']) as $key => $val) {

Code: Select all


foreach($this->CleanArray(explode($blockInfo['delimiter'], $data)) as $key => $val) {


Code: Select all


foreach(explode($blockInfo['delimiter'], $data) as $key => $val) {

Code: Select all


foreach($this->CleanArray(explode($blockInfo['delimiter'], $blockInfo['items'])) as $key => $val) {

Code: Select all


foreach(explode($blockInfo['delimiter'], $blockInfo['items']) as $key => $val) {

Code: Select all


foreach($this->CleanArray(explode($blockInfo['delimiter'], $blockInfo['values'])) as $key => $val) {

Code: Select all


foreach(explode($blockInfo['delimiter'], $blockInfo['values']) as $key => $val) {



Just some notices...

Notice that the file picker stuff will change again in later releases since the filepicker will be removed from AdvancedContent and replaced by GBFilePicker. This means {content block_type="image/file"} won't be valid anymore.
Maybe i will keep it the way it is for one or two releases but will mark it as deprecated until everyone noticed it and changed the image block in the template to {content_image} or {content_module module="GBFilePicker"}

Anyway i've seen in the announcements that the devs changed the behaviour of the {content_image} tag in CMSms 1.9 to always use the image uploads dir in backend and print out absolute urls in frontend (dunno if this is caused by the poll here or the feature request but i don't care; it is an improvement and this is the only important thing to me).

But GBFilePicker only refers to the uploads dir and prints out relative urls (last one cannot be changed because the output is performed by the {content_module} tag and this only prints out what is stored in the db. And in the DB there only will be stored urls relative to the uploads dir due to compatibility reasons if uplads dir changes).

So {content_image} and {content_module module="GBFilePicker" file_type="image"} won't be the same anymore (whereas {AdvancedContent block_type="image"} trys to act like the same at the moment; but may fail in CMSms 1.9).

But this seems trivial to me since GBFilePicker it is not meant to be the same like {content_image} and the blocktype image/file won't be supported anymore by AdvancedContent. Each one will look in its own prefered directory and each one will perform its own output. So each one will work with the default content type as well as with the AdvancedContent type. So this might be no problem.

Just keep that in mind when updating to CMSms 1.9 or to AdvancedContent 0.6+



EDIT:

Sorry, for some reason i provided the wrong filename.
I updated filename here.
Anyway there is a final release 0.5.1 that contains that bugfixes.
Last edited by NaN on Fri Oct 08, 2010 7:36 pm, edited 1 time in total.
User avatar
NikNak
Forum Members
Forum Members
Posts: 183
Joined: Fri Oct 02, 2009 2:28 pm

Re: AdvancedContent

Post by NikNak »

Yes - I'm going to be very careful with that upgrade to 1.9.

Thanks again
NaN

Re: AdvancedContent

Post by NaN »

First test release of v.0.6 can be downloaded here. (for testing only. it is not recommended to use this on a live site without testing it at least on a localhost or another playground page)

Notice:
-FilePicker has been removed so block_type image/file is not supported anymore. Use the GBFilePicker instead (read doku of GBFilePicker how to use since params are not the same like in AdvancedContent).

- Block_type note was also removed.

- Added param block_group to group multiple blocks in one fieldset.

- FrontendAccess is checked by using the eventmanager. That means you don't have to use {AdvancedContent} plugin to redirect if user is not logged in.

I hope i fixed all known bugs. If not, please report.

Edit:
- Fixed some bugs with contentblocks not shown when reloading the edit page by changinf the contenttype or the template. Please download again.
Last edited by NaN on Tue Sep 28, 2010 11:40 pm, edited 1 time in total.
NaN

Re: AdvancedContent

Post by NaN »

Version 0.6 is in the Forge now.

I added some preferences to store the "toggle status" of the content blocks per page or per template and to set a default status of new added blocks.
AdvanedContent options tab can also be toggled off.

Module should be ready for CMSms 1.9 (as long as nothing big changes until final release).

Some note to the SVN users:
Current release is in directory /tags/0.6.+/
The trunk dir is for 0.7 that will only work with CMSms 1.9 due to some funtions that are only available there.
Locked

Return to “Modules/Add-Ons”