TinyMCE - can I prevent <ul> tags from being written

11 posts by 3 authors in: Forums > CMS Builder
Last Post: April 4, 2012   (RSS)

By meg - March 28, 2012

Is there a way to prevent <ul> tags from being written when you select the "Unordered List" button in the WYSIWYG?

So, instead of this being written...

<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>

this would
<li>Item 1</li>
<li>Item 2</li>

I initially tried listing all of the the "valid_elements" in the wysiwyg.php file and not listing <ul> but that didn't work.

Any other suggestions?

Re: [meg] TinyMCE - can I prevent <ul> tags from being written

By Jason - April 2, 2012

Hi,

One thing you could do is to strip out the <ul> tags using PHP on the front end.

EXAMPLE:

<?php echo str_replace("</ul>", "", str_replace("<ul>", "", $record['content']));?>

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] TinyMCE - can I prevent <ul> tags from being written

By meg - April 2, 2012

Does that strip <ul> tags from all of the page or just what's generated in the CMS?

Essentially, I have a multi-tier tab script on the page that uses <ul> tags to generate the tabs. When I insert a list, using the WYSIWYG, that appears within the tabs, there is a code conflict, which I can't seem to resolve. (I've tried other tab scripts, but then there's code conflicts with other scripts on the page.) The only way, as a work around, is to remove the <ul> tags from the lists, and everything works fine.

Do you think this is the best solution?

Re: [meg] TinyMCE - can I prevent <ul> tags from being written

By Jason - April 2, 2012

Hi,

In the example above, the <ul> tags will only get stripped out of the content field of the record. It shouldn't affect anything else on the page.

Thanks
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] TinyMCE - can I prevent <ul> tags from being written

By meg - April 3, 2012

One last question. If I'm trying to remove the <ul> tags from a multi-listing section with multiple form fields, how would I do that?

For example:
$record would be $packagesRecords ?

content would be tab1_description, tab2_description ?

Here's what I came up with and the error is below:
<?php echo str_replace("</ul>", "", str_replace("<ul>", "", $packagesRecords['tab_description_1, tab_description_2, tab_description_3, tab_description_4, tab_description_5']));?>


Notice: Undefined index: tab_description_1, tab_description_2, tab_description_3, tab_description_4, tab_description_5

Re: [meg] TinyMCE - can I prevent <ul> tags from being written

By (Deleted User) - April 3, 2012 - edited: April 3, 2012

Hi meg,

The $packageRecords variable would be an array, so if each field (tab_description_1 etc etc) is a separate field in the table then you would ahve to do this:
<?php

echo str_replace("</ul>", "", str_replace("<ul>", "", $packagesRecords['tab_description_1']));
echo str_replace("</ul>", "", str_replace("<ul>", "", $packagesRecords['tab_description_2']));
echo str_replace("</ul>", "", str_replace("<ul>", "", $packagesRecords['tab_description_3']));
echo str_replace("</ul>", "", str_replace("<ul>", "", $packagesRecords['tab_description_4']));
echo str_replace("</ul>", "", str_replace("<ul>", "", $packagesRecords['tab_description_5']));

?>

This will output the content of each 'tab_description' field with the<ul></ul> tags removed.

Let me know if this helps,

Tom

Re: [Tom P] TinyMCE - can I prevent <ul> tags from being written

By meg - April 3, 2012

Thank you, but I'm still getting the error "Undefined index:" for all of the tab fields. Any thoughts as to why?

Re: [meg] TinyMCE - can I prevent <ul> tags from being written

By (Deleted User) - April 3, 2012

Hi Meg,

How are you creating $packagesRecords and what are the field names for the wysiwyg content editors that you want to output the content from?

Tom

Re: [Tom P] TinyMCE - can I prevent <ul> tags from being written

By meg - April 4, 2012

Here's mine set-up.

Header:

<?php header('Content-type: text/html; charset=utf-8'); ?>
<?php
$libraryPath = 'cms/lib/viewer_functions.php';
$dirsToCheck = array('D:/inetpub/companyname/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

list($publishing_packagesRecords, $publishing_packagesMetaData) = getRecords(array(
'tableName' => 'publishing_packages',
));

?>
<?php
echo str_replace("</ul>", "", str_replace("<ul>", "", $publishing_packagesRecords['tab_description_1']));
echo str_replace("</ul>", "", str_replace("<ul>", "", $publishing_packagesRecords['tab_description_2']));
echo str_replace("</ul>", "", str_replace("<ul>", "", $publishing_packagesRecords['tab_description_3']));
echo str_replace("</ul>", "", str_replace("<ul>", "", $publishing_packagesRecords['tab_description_4']));
echo str_replace("</ul>", "", str_replace("<ul>", "", $publishing_packagesRecords['tab_description_5']));
?>


Then the tab content using the WYSIWYG content editors:
<?php foreach ($publishing_packagesRecords as $record): ?>

<!--Start First Tab-->
<?php if($record['tab_description_1']): ?>
<div id="fragment-<?php echo $record['num'] ?>a">
<!--Scrolling DIV's--><div class="scroll-pane">
<?php echo $record['tab_description_1'] ?>
</div></div>
<?php endif ?>
<!--END First Tab-->

<!--Start Second Tab-->
<?php if($record['tab_description_2']): ?>
<div id="fragment-<?php echo $record['num'] ?>b">
<!--Scrolling DIV's--><div class="scroll-pane">
<?php echo $record['tab_description_2'] ?>
</div></div>
<?php endif ?>
<!--END Second Tab-->

<!--Start Third Tab-->
<?php if($record['tab_description_3']): ?>
<div id="fragment-<?php echo $record['num'] ?>c">
<!--Scrolling DIV's--><div class="scroll-pane">
<?php echo $record['tab_description_3'] ?>
</div></div>
<?php endif ?>
<!--END Third Tab-->

<!--Start Fourth Tab-->
<?php if($record['tab_description_4']): ?>
<div id="fragment-<?php echo $record['num'] ?>d">
<!--Scrolling DIV's--><div class="scroll-pane">
<?php echo $record['tab_description_4'] ?>
</div></div>
<?php endif ?>
<!--END Fourth Tab-->

<!--Start Fifth Tab-->
<?php if($record['tab_description_5']): ?>
<div id="fragment-<?php echo $record['num'] ?>e">
<!--Scrolling DIV's--><div class="scroll-pane">
<?php echo $record['tab_description_5'] ?>
</div></div>
<?php endif ?>
<!--END Fifth Tab-->

<?php endforeach ?>


I removed the tab <li>'s to keep things short and sweet. Thanks so much for your assistance with this!