Changing Field Type

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

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

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

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

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

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: [greg] Changing Field Type

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

Re: [shannonr] Changing Field Type

HI - OK, I tried this and the console is telling me I have increased the character limit, but when adding text into the field its still limited to 255 characters. Plus I notice in the console that the NULL flag for the 2 columns I altered is now set to YES.
Also when running a SELECT * FROM cms_uploads LIMIT 100 query, it shows up several entries that I previously deleted (could this be the cause of the NULL value?)
So not out of the woods yet... [:|]