- Posts: 404
COMMUNITY FORUM
tag.php introtext limit shows code
- Odin Mayland
-
Topic Author
- Offline
- Platinum Member
Less
More
9 years 2 months ago #151696
by Odin Mayland
tag.php introtext limit shows code was created by Odin Mayland
I found this code in the forums but it is not stripping the code:
181.224.134.27/~icd10mon/index.php?option=com_k2&view=itemlist&layout=tag&tag=EHR&task=tag&Itemid=425
The default intro text limit works fine: 181.224.134.27/~icd10mon/index.php?option=com_k2&view=itemlist&layout=category&task=category&id=83&Itemid=90
<div class="tagItemIntroText">
<?php echo K2HelperUtilities::wordLimit($item->introtext, 40); ?>
</div>
181.224.134.27/~icd10mon/index.php?option=com_k2&view=itemlist&layout=tag&tag=EHR&task=tag&Itemid=425
The default intro text limit works fine: 181.224.134.27/~icd10mon/index.php?option=com_k2&view=itemlist&layout=category&task=category&id=83&Itemid=90
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
9 years 2 months ago #151717
by Krikor Boghossian
Replied by Krikor Boghossian on topic tag.php introtext limit shows code
Hello Jeff,
If you are using wordlimit, then all HTML tags are being stripped, this means that the <script> tag is being stripped and the content of that script is being treated as plain text.
If you are using wordlimit, then all HTML tags are being stripped, this means that the <script> tag is being stripped and the content of that script is being treated as plain text.
Please Log in or Create an account to join the conversation.
- Odin Mayland
-
Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 404
9 years 2 months ago #151728
by Odin Mayland
Replied by Odin Mayland on topic tag.php introtext limit shows code
Thank you for the help.
How do I display the first 50 words of the introtext without the stripped code issue?
How do I display the first 50 words of the introtext without the stripped code issue?
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
9 years 2 months ago #151745
by Krikor Boghossian
Replied by Krikor Boghossian on topic tag.php introtext limit shows code
I would suggest using a different editor for introtext and fulltext or manually define an introtext using the read more button.
This way you won't have to use a wordlimit.
You can also use str_replace() - php.net/manual/en/function.str-replace.php in your template to strip the script altogether.
This way you won't have to use a wordlimit.
You can also use str_replace() - php.net/manual/en/function.str-replace.php in your template to strip the script altogether.
Please Log in or Create an account to join the conversation.
- Odin Mayland
-
Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 404
9 years 2 months ago #151751
by Odin Mayland
Replied by Odin Mayland on topic tag.php introtext limit shows code
I fully agree, but this is a migrated website in which the previous webmaster did not tell the clients about the readmore feature. So there are 1566 k2-items that need to now show an "intro" on the blog layout page.
I saw other posts that other users said the wordlimit works but it shows code for me. Is there another way?
I saw other posts that other users said the wordlimit works but it shows code for me. Is there another way?
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
9 years 2 months ago #151752
by Krikor Boghossian
Replied by Krikor Boghossian on topic tag.php introtext limit shows code
Yes with 1566 items, the manual method is surely out of the question.
You can try with the str_replace() method to completely remove that script from the introtext in your template overrides.
You can try with the str_replace() method to completely remove that script from the introtext in your template overrides.
Please Log in or Create an account to join the conversation.
- Odin Mayland
-
Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 404
9 years 2 months ago #151756
by Odin Mayland
Replied by Odin Mayland on topic tag.php introtext limit shows code
Would I have to list all the needles of code? Is there any code that you know would work that I can paste in?
Another option would be a database replace, where I insert a <hr id="system-readmore" /> after the first 50 words. I don't know how to do this but it may be another option....
Another option would be a database replace, where I insert a <hr id="system-readmore" /> after the first 50 words. I don't know how to do this but it may be another option....
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
-
- Offline
- Platinum Member
Less
More
- Posts: 15920
9 years 1 month ago #151790
by Krikor Boghossian
Replied by Krikor Boghossian on topic tag.php introtext limit shows code
Yes you could use an SQL script to manually insert the <hr id="system-readmore" /> but you will still need to keep entering the limit on newly created items.
If you use str_replace()
A more robust solution would be to use preg_replace - php.net/manual/en/function.preg-replace.php - to completely remove all
If you use str_replace()
$needle = '<script>'.
' contents'.
' contents'.
'</script>';
$introtext = str_replace( $needle, '', $item->introtext );
echo $introtext;
A more robust solution would be to use preg_replace - php.net/manual/en/function.preg-replace.php - to completely remove all