Changing field from upload to wysiwyg

10 posts by 4 authors in: Forums > CMS Builder
Last Post: August 20, 2009   (RSS)

By NigelGordijk - July 27, 2009 - edited: July 27, 2009

Hi, All.

I have a site that is already set up with CMSB and articles are already in place: http://www.yallaf1.com.. The main image is an upload field, but the client would like to change this to a wysiwyg. When I change the field type in the admin area from upload to wysiwyg, the main images that have already been uploaded disappear from existing articles. Is this type of field type change even possible?

Many thanks,
Nigel Gordijk

Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net

Re: [NigelGordijk] Changing field from upload to wysiwyg

By Dave - July 27, 2009

Hi Nigel,

That's not anything we ever planned for but it should work.

Try switching it to a wysiwyg field and then clicking the insert photo button the wysiwyg and then browse. It should show the photos you've already uploaded and allow you to insert them.

Let me know if that works for you.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Changing field from upload to wysiwyg

Hi, Dave.

I was hoping that the pictures that have already been put in the articles using the upload feature would automatically appear in the correct place when this field was changed to wysiwyg. There are dozens of articles and pictures, so I'm trying to avoid the extra work! :-)

At the moment, when I change the field type from upload to wysiwyg and then view the live page(s), I see the following error message on the page where the picture(s) should appear:

Warning: Invalid argument supplied for foreach() in /home/yallaf5/public_html/index.php on line 265
Nigel Gordijk

Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net

Re: [NigelGordijk] Changing field from upload to wysiwyg

By Dave - July 27, 2009

Hmm, yea there's no easy way to make that switch. Because upload fields loop over the uploads like this:
<?php foreach ($record['uploads'] as $upload): ?>

And when you switch it to a wysiwyg it would put the wysiwyg content in the field $record['uploads'] so you'd get an error if you tried to loop over it. And there's no pre-configured way to display existing uploads in a wysiwyg.

Any workarounds I can think of also involve a fair bit of extra work. The simplest might to switch the code to display the wysiwyg content and re-insert the already uploaded images in the wysiwyg.

Why does your client want a wysiwyg instead of an upload field? Is there another way around that? Perhaps adding a new wysiwyg and keeping the existing upload field?
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Changing field from upload to wysiwyg

>>Why does your client want a wysiwyg instead of an upload field? Is there another way around that? Perhaps adding a new wysiwyg and keeping the existing upload field? <<

I think he wants the option of adding Flash slideshows or videos as well as static photos. Adding an extra field sounds more feasible.

Thanks for the advice, Dave.
Nigel Gordijk

Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net

Re: [Dave] Changing field from upload to wysiwyg

Hi, Dave.

Is there a piece of code that I can use so the page template skips, say, the wysiwyg field if nothing has been entered into it? I'm getting the following error message:

Notice: Undefined variable: top_storiesRecord in /home/yallaf5/public_html/stories.php on line 279

Kind regards,
Nigel Gordijk

Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net

Re: [NigelGordijk] Changing field from upload to wysiwyg

By InHouse - July 28, 2009

Hi Nigel,

Sure, we do this all the time. Very useful. There are several ways of coding this but the basic idea is to check the field to see if it has content before writing the field to the screen.

Example:
<?php
if ($articlesRecord['subtitle']): // If subtitle field has content, then... (technically reads as: if `subtitle` is TRUE then... )
?>
<h3><?php echo $articlesRecord['subtitle'] ?></h3>
<?php endif; ?>


The Header3 tags are not needed, just happen to be there in my current project.

You can add any block or inline styling/code you want within the IF stmt.

Hope this helps,
J.

Re: [NigelGordijk] Changing field from upload to wysiwyg

Hi Nigel,

There's an interesting post that might give you some ideas for future flexibility.

http://www.interactivetools.com/iforum/gforum.cgi?post=59074

Best,

Jerry Kornbluth

Learn more... Do more...
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 from upload to wysiwyg

Thanks, Jerry.
Nigel Gordijk

Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net