Changing Field Type

12 posts by 4 authors in: Forums > CMS Builder
Last Post: November 30, 2012   (RSS)

By ILLUME-MEDIA-LABS - July 11, 2012

Hi,

Backend questions:

Is it possible to change the field from textfield to wysiwyg box for the captions (info1, info2, etc) in the image upload area?

The current character count is limited, I need to expand that, plus have the ability to add html attributes.

Also, is there a way to dynamically add text boxes, much like the way the image upload functions? This pertains to galleries. I want to be able to insert video code in between images, or have a gallery entirely of videos.

I want to be able to add or delete text boxes at will, and use a foreach statement in the frontend to pull the # of boxes.

Does that make sense?

Thanks

Re: [Illume Magazine] Changing Field Type

By gkornbluth - July 11, 2012

Lots of questions...

1) I don't think it's possible to change the values of the info fields without hacking the underlying code.

2) I did some research a while back and have attached a list of the files that contained a reference to those fields. I never pursued the matter, but the list is attached. Good luck.

3) I created a pretty robust character counter and it's available on the user submitted addons page at http://www.interactivetools.com/add-ons/detail.php?Character-Counter-For-Text-Fields-1051.

4) Don't know what you mean by dynamically add text boxes.

5) I'm not sure what you mean by videos in between images, but just finished a project using the free jwplayer that needed to accept either videos or stills and present the appropriate code. It centered around if statements like:
<?php foreach ($record['image_or_video'] as $upload): ?><?php if ($upload['extension'] == 'jpg' ): ?><?php $type = 'jpg' ?><a href="<?php echo $record['_link'] ?>"><img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /></a>
<?php endif ?><?php endforeach; ?><?php foreach ($record['image_or_video'] as $upload): ?> <?php if ($upload['extension'] == 'mp4' ): ?><?php $type = 'mp4' ?><?php foreach ($record['video_image'] as $upload): ?><a href="<?php echo $record['_link'] ?>"><img src="<?php echo $upload['thumbUrlPath'] ?>" width="<?php echo $upload['thumbWidth'] ?>" height="<?php echo $upload['thumbHeight'] ?>" alt="" /><br />VIDEO CLIP<br />AVAILABLE</a>

For the list page. And for the detail page:
<?php if ($videosRecord['image_or_video']): ?>
<table width="100%" border="0" align="center" cellpadding="5">
<tr >
<?php foreach ($videosRecord['image_or_video'] as $upload): ?>
<?php if ($upload['extension'] == 'mp4'): ?>
<td align="center" valign="top" >
<span class="body-text-small-8"><br />
<?php echo $upload['info1']; ?></span><br />
<span class="body-text-small-8"><?php echo $upload['info2']; ?><br />
<br />
</span>
<div id="container">&nbsp;</div>
<script type="text/javascript">
jwplayer("container").setup({
'controlbar': 'bottom',
'file': 'http://96.0.19.97<?php echo $upload['urlPath'] ?>',
'height': '250',
'width': '225',
'image': 'http://96.0.19.97<?php foreach ($videosRecord['video_image'] as $upload): ?><?php echo $upload['thumbUrlPath2'] ?><?php endforeach ?>',
'autostart': 'false',

modes: [
{ type: "html5" },
{ type: "flash", src: "player.swf" }
]

});
</script>
<br />
<br />
</td>
<?php else: ?>

<td valign="top" align="center"><br />
<span class="body-text-small-8"> <?php echo $upload['info1']; ?></span><br />
<span class="body-text-small-8"> <?php echo $upload['info2']; ?><br />
<br />
</span><img src="<?php echo $upload['thumbUrlPath2'] ?>" width="<?php echo $upload['thumbWidth2'] ?>" height="<?php echo $upload['thumbHeight2'] ?>" alt="" /><br />
<br />

<?php endif ?></td>

<?php endforeach ?>
<?php endif ?>

Hope that answers some of your questions.

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Changing Field Type

By ILLUME-MEDIA-LABS - July 13, 2012

Hi gkornbluth,

Thanks for the pointers. This really helped! I had enough time to tackle the field type.

Files to edit: uploads.ini.php, uploadModify.php, editField.php & style.css

Uploads.ini.php (changed type from varchar to medium text)
[info5]
order = 32
customColumnType = "mediumtext NOT NULL"


Although I can't edit just 1 info field. This would require a lot of code mod. So I just kept it simple and edited the code that will modify all the info fields.

uploadModify.php (from textfield to text area)

$fieldHTML = "<textarea class='text-input1' type='text' name='$formFieldName' cols='70' rows='10' />" .htmlspecialchars($uploadRecord[$infoFieldname], ENT_QUOTES). "</textarea>";

I also removed the character limit of 255.

Next I will be working on the gallery over the weekend.

Many thanks for your help!

Re: [Illume Magazine] Changing Field Type

By gkornbluth - July 13, 2012

Glad it helped,

You mentioned 4 files but only noted the changes you made to 2 of them.

What did you do to the other 2? (editField.php & style.css )

Thanks,

Jerry
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Changing Field Type

By shannonr - November 27, 2012

Hi - I tried this but was getting a mySQL error:

MySQL Error: Data too long for column 'info2' at row 1

Is this easy to sort? Can I do this in PHPMyAdmin?
Thanks
Shannon

Re: [shannonr] Changing Field Type

By gkornbluth - November 27, 2012

Sorry Shannon.

I don't know the answer to that one.

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Changing Field Type

By shannonr - November 27, 2012

Hello Jerry - thanks for that... (sort of!). So what's the answer to getting more text into the info field - any idea? Did you try this procedure? Anyone else know?
Thanks again
Shannon

Re: [shannonr] Changing Field Type

By gregThomas - November 28, 2012

Hi Shannon,

The changes your currently making will be overwritten if you upgrade CMS Builder at a later date, and we don't provide official support for them.

If you do want to continue, it is possible to increase the character limit of a field using the MySQL console plugin, which is a free plugin you can find here:


http://www.interactivetools.com/add-ons/?user_submitted=1


Once you have installed the plugin, go to the MySQL console link in the plugins section, this will take you to a page where you can run custom MySQL commands. To see the current layout of your upload table use this command:

DESCRIBE cms_uploads

You should find that the character limit of the info1 field is 255 characters. You can increase it using this command:

ALTER TABLE cms_uploads modify info1 VARCHAR(400) ;

Now you should be able to add up to 400 characters of text to the field.

Let me know if you have any problems.

Thanks
Greg Thomas







PHP Programmer - interactivetools.com

Re: [greg] Changing Field Type

By shannonr - November 28, 2012

Hi Greg - thats brilliant, thanks for the info!...