Limit WYSIWYG options per section

20 posts by 7 authors in: Forums > CMS Builder
Last Post: June 15, 2012   (RSS)

By sublmnl - October 28, 2009

I searched and did not find what I was looking for.
Dave and the gang, have you guys been able to limit the wysiwyg options per section yet?

Right now, we modify the CSS so the styling is limited as well as some of the 'insertable' pieces from the wysiwyg.

It would be nice if we could allow some things in some sections and not in others. (don't want clients getting carried away you know :) )

For example, my first challenge with this is for a site that really doesn't have advertisers per say.
So it doesn't make sense to me to upload a banner management tool just to manage two little spots on the homepage to link to other pages in the site.

BUT!!! If I could limit this one section to two uploads and modify links for those images, that would be all I needed.

I can't think of our other challenges from past projects but that one came instantly to mind.

Any and all ideas are welcome.

Re: [sublmnl] Limit WYSIWYG options per section

By Dave - October 28, 2009

Hi sublmnl,

There's no support for that yet. If you are comfortable editing some PHP, though, I could point you in the right direction to make some updates to /lib/wysiwyg.php to show different wysiwygs for different sections or fields.

Let me know what section or fieldnames you want it to be different for and what wysiwyg differences you want.
Dave Edis - Senior Developer
interactivetools.com

Re: [sublmnl] Limit WYSIWYG options per section

By Donna - October 29, 2009

Hi sublmnl,

Just a quick question -- if all you need for the second field is the image uploader & link ability, could you instead simply use an upload field?
Donna

--
support@interactivetools.com

Re: [Donna] Limit WYSIWYG options per section

By sublmnl - October 29, 2009

Well for every site we build we turn off the image upload in the tinyMCE (and a few others) we have separate uploads fields for every section that has a wysiwyg editor on it.
That way we can control the positioning of images on the page and not the client. (perhaps we should try letting go of control... maybe maybe not)

For the two upload spots I mention above, the client wants the ability to link the 'product' to its page.

simplyfing it a little... the banner management tool would work from a control standpoint for both the client and us, but do not need all the setup involved in just simply adding an image and linking it to the proper page within the site.... plus we don't need any wizzbang reporting/stats on those clicks.

Re: [sublmnl] Limit WYSIWYG options per section

By Donna - October 29, 2009 - edited: October 29, 2009

What about using an extra info field for the URL it needs to link to?

I totally understand the control thing -- I'm a fan of it, too. (Heck, I almost never use WYSIWYG fields because I'm too much of a control freak!)

Using an info field would probably make it super easy, though -- you'd end up with something like this:

<a href="<?php echo $upload['info1'] ?>"><img src="<?php echo $upload['thumbUrlPath'] ?>" /></a>

I've stripped out a few things there to make it easy to read, height & width and anything else you need can, of course, be added back in, as well as any other upload code you need for the field.

Anyway, that's a nice easy way to get a user to upload an image and include the URL it's supposed to link to all in one. Does that look like it would work for you?
Donna

--
support@interactivetools.com

Re: [Donna] Limit WYSIWYG options per section

By sublmnl - October 29, 2009 - edited: October 29, 2009

So a text field would be the URL and put it in the HREF quotes?
Kind of like how we treat the meta info that gets included in the Quotes?

<meta name="Keywords" content="<?php echo $aboutRecord['meta_keywords'] ?>" />
<meta name="Description" content="<?php echo $aboutRecord['meta_description'] ?>" />



or are you saying the title and caption fields that you see after you upload an image would be the URL and put that in the HREF quotes?

I actually use one of the fields for the ALT tag like this:

<img src="<?php echo $upload['urlPath'] ?>" width="<?php echo $upload['width'] ?>"
height="<?php echo $upload['height'] ?>" alt="<?php echo $upload['info1'] ?>" align="right" />


I could probably use the info2 for the URL if this is what you mean..... (?)

Re: [sublmnl] Limit WYSIWYG options per section

By Donna - October 30, 2009

Hi there,

Pretty much like any field, really. You just grab the code that echos that particular field and stick it where you want it -- exactly like the alt text. :)

Since you're using info1 for the alt text, you're right, you'd grab info2 instead and just stick the echo code into the spot where you want that URL to be output.

Then, change it via the field editor so the label says "URL to link to" or something like that so your users know what they should be doing there, and it'll auto populate.
Donna

--
support@interactivetools.com

Re: [Donna] Limit WYSIWYG options per section

By sublmnl - October 30, 2009

ah ha.

we'll give it a shot.

thanks again.

still wouldn't mind seeing the option-able stuff per section in the wysiwyg sometime soon.

hint hint.
[;)]

Re: [sublmnl] Limit WYSIWYG options per section

By Dave - November 2, 2009

Hi sublmnl,

>still wouldn't mind seeing the option-able stuff per section in the wysiwyg sometime soon.

Here's how to do it with code. This is for advanced users only:

- Copy /cmsAdmin/lib/wysiwyg.php to /cmsAdmin/lib/wysiwyg_custom.php (if you haven't already)
- Backup /cmsAdmin/lib/wysiwyg_custom.php
- Open that file for editing
- Search for "display field"
- add this code above it:


// call custom wysiwyg functions named: initWysiwyg_sectionName_fieldName() or initWysiwyg_sectionName()
if (__FUNCTION__ == 'initWysiwyg') {
$fieldnameWithoutPrefix = preg_replace("/^field_/", '', $fieldname);
$fieldSpecificFunction = "initWysiwyg_{$GLOBALS['tableName']}_$fieldnameWithoutPrefix";
$sectionSpecificFunction = "initWysiwyg_{$GLOBALS['tableName']}";

if (function_exists($fieldSpecificFunction)) { return call_user_func($fieldSpecificFunction, $fieldname, $uploadBrowserCallback); }
if (function_exists($sectionSpecificFunction)) { return call_user_func($sectionSpecificFunction, $fieldname, $uploadBrowserCallback); }
}


// display field


For every field that you want a custom wysiwyg for create a copy of the initWysiwyg() function named initWysiwyg_tablename_fieldname (example: initWysiwyg_news_content).

You can how specify specify the wysiwyg looks on a per section or per field basis.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com