Joomla trim a class

160 Views Asked by At

Hy everyone I got this code

<?php if($this->item->params->get('itemRelatedIntrotext')): ?>
            <div class="itemRelIntrotext"><?php $new_string = substr($item->introtext, 0, 220); echo $new_string; ?></div>
            <?php endif; ?>

is bringing introtext, but its bringing the text with all the html code

<p class="mmbodytext">Dentro del <strong>Plan Estratégico</strong> de la campaña y como una de las líneas de acción de la comunicación está el <strong>Marketing Online</strong>. Su función, educar una...</p>

When the text is called i need to remove class="mmbodytext" and from it

2

There are 2 best solutions below

0
On BEST ANSWER

If you are searching for an easy way to remove all tags you could use strip_tags().

<?php echo substr(strip_tags($item->introtext), 0, 220); ?>

Reference: strip_tags

1
On

Just figure it out...

<?php if($this->item->params->get('itemRelatedIntrotext')): ?>
            <div class="itemRelIntrotext"><?php $new_string = substr($item->introtext, 0, 220); ?>
            <?php $string = $new_string;
                $wordlist = array("mmbodytext","<strong>");

                foreach ($wordlist as $word) {
                    $string =str_replace($word, '', $string);
                }
                echo $string;
                ?>
            </div>
            <?php endif; ?>