HTML Tags Publishing

11 posts by 4 authors in: Forums > CMS Builder
Last Post: July 18, 2013   (RSS)

By dkane11 - June 25, 2013

I am having an issue with the HTML tags displaying live on the web site for articles.

I am not putting the tags in the WYSIWYG editor and have confirmed that the tags are correct in the HTML editor window (screenshot attached). 

When I preview the page within the Admin panel it displays fine without the tags, but when I save and publish to my site the tags display on the live site.

I just upgraded to the current version to see if that was the issue, but I am experiencing the same problem.

Has anyone else encountered this issue?

Thanks.

Attachments:

example_005.jpg 343K

By mizrahi - June 25, 2013

Is it possible you are using the "htmlencode()" function around these fields in your html file?

It would look something like this...

<?php echo htmlencode($news['content']) ?>

If so, try this...

<?php echo $news['content'] ?>

By dkane11 - June 26, 2013

Thank you!  I did have the htmlencode() function in my html file code.  Once I removed that function it solved the issue.

Thanks again for the help!

Just as an addendum to this item:

The recent inclusion of the htmlentities() function to parts of the auto-generated code can trip you elsewhere also. For example, we often have to manually create the linking URL, not being able to always use the on-board "_link" value. Be very careful with your use of htmlentities when doing someting like:

<a href="targetPage.php?<?php echo htmlentities($record['title']).'-'.$record{'num'];?>link</a>

The use of this function will trigger the URL spaces and other special characters to convert to their character codes. This _may_ have an impact on your SEO and it will certainly make life less happy for your users and Google Analytics reports.

Somewhere in this forum, Dave posted a function to clean up a $record['title'] value used in this way, but I've not been able to find it.

Just FYI.

J.

By gregThomas - July 5, 2013

Hi J.,

The function that encodes a string for use in a URL is urlencode:

<a href="targetPage.php?<?php echo urlencode($record['title']).'-'.$record{'num'];?>link</a>

This will convert any special characters like '&' or '?' to there URL safe equivalents, and ensure you don't end up with corrupted URL's.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

Thank you Greg!  Very helpful.

HI Greg,

Just noticed that the urlencode function is replacing spaces with '+' signs. Can you please clarify why that is vs. using hyphens?

Cheers,

J.

This seems like a great answer, Greg... but it throws up another question. If plus signs are the correct "spacer symbol" in a URL why does the native CMSB _link then use hyphens when replacing spaces in the SEO-text section of a URL?

I'm working with a big site right now that uses a mix of urlencode and the native _link's. They are very big on analytics and being able to copy-n-paste URLs from web pages into emails etc. This difference is going to cause them fits.

Can you suggest a change in the supporting functions that would make this uniform?

Cheers,

J.

By gregThomas - July 16, 2013

Hi J,

The native CMS Builder uses hyphens as they produce more aesthetically pleasing URL's than plus signs, and as the code gets the number from the end of the link and doesn't use the SEO text string, the string doesn't need to validate.

The _link for a record is generated using the getFilenameFieldValue function, you can see where it's generated on line 425 of viewer_functions.php in the cmsAdmin lib directory. If you want to have you links in the same format as CMS Builder you could use this method:

  <a href="targetPage.php?<?php echo getFilenameFieldValue($record,'title').$record['num'];?>" >link</a>

So the getFilenameFieldValue function coverts a string into a format that would be safe to use for a file name. You need to pass in the record array that contains the field you want to use, and the name of the field you want to covert to a file/URL format. This example would replace the code that is used in this post:

http://www.interactivetools.com/forum/forum-posts.php?postNum=2231130#post2231130

Another option would be to change your viewer_functions.php to use url_encode, although we don't recommend this as it involves changing core CMSB files, and we wouldn't be able to provide support for any issues produced. 

Let me know if you have any questions.

Cheers

Greg

Greg Thomas







PHP Programmer - interactivetools.com