Announcement

Collapse
No announcement yet.

Bad html in fragment/product descriptions breaks responsive layout

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Bad html in fragment/product descriptions breaks responsive layout

    Some clients really like to add html to their fragment text and product text. Not infrequently this html is bad html, and whilst html4 and non responsive sites would tolerate it, html5 and responsive sites will not and stray divs and unclosed tags can break the responsibe layout.

    This problem can be solved by using 'html fixer' from http://www.barattalo.it/html-fixer/ and saving the file htmlfixer.class.php in your site folder and probably adding it to Additional Files.

    You have two options.
    To clean the html but still leave the html coding the client intended:
    Code:
    <actinic:block php="true" selectable="false" >
    		include_once 'htmlfixer.class.php'; 
    		$dirty_html = <<<ENDOFDESCRIPTION
    		<actinic:variable formatting="style|fragment-text" encoding="actinic" name="FragmentText" />
    ENDOFDESCRIPTION;
    		$a = new HtmlFixer();
    		echo $a->getFixedHtml($dirty_html);
    	</actinic:block>
    To remove coding altogether as well as the !!< and >!!:

    Code:
    <actinic:block php="true" selectable="false" >
            include_once 'htmlfixer.class.php';
            $dirty_html = <<<ENDOFDESCRIPTION
            <actinic:variable name="FragmentText" encoding="perl" selectable="false" />
    ENDOFDESCRIPTION;
            $stringsToRemove = array('!!<', '>!!');
            $dirty_html = str_replace($stringsToRemove, '', $dirty_html);
            $a = new HtmlFixer();
            echo $a->getFixedHtml($dirty_html);
    </actinic:block>
    I am grateful to Norman for refining this and for impressing on me that the ENDOFDESCRIPTION; must be against the left edge, it cannot be indented.
    Jonathan Chappell
    Website Designer
    SellerDeck Website Designer
    Actinic to SellerDeck upgrades
    Graphicz Limited - www.graphicz.co.uk
Working...
X