1

I am trying to remove the link on my image on the Tag page (where all the artcile with the same tag are displayed). The image is placed with the <img> tag in introtext, it's not an intro image.

I did find the correct php function:

$notagintrotex =strip_tags( $this->item->introtext, '<img>');
echo $notagintrotex;

But I can't find which file I have to override. I have seen this question but it seems there have been some changes since Joomla 3.3.1. on templates/yourtemplate/html/com_tags/tag/default_items.php

  • Sorry, it is not clear to me what you want to do. What menu item type you have? And what you are trying to remove? The image (tag image or item image) or a possible link that this image has? – FFrewin Jul 17 '14 at 21:46
  • I am sure you just edit the intro image on the default articles view of com_content, TAGS just pulls the article layout in, it doesnt generate it own. I just tried it in the template HTML override of a WARP7 template and it certainly worked – MOLEDesign Jul 17 '14 at 23:09
  • @FFrewin: For the menu-item: I am not using a menu-item. I get to the page I am talking about by clicking on a tag, just below the article title. This page where I am redirected display all the articles that are tagged with the same tag. This last page is the one I have issue. So I don't have a menu item redirecting there, the link to this page is generated by the Tag component. – MagTun Jul 22 '14 at 16:41
  • @MorganUK: the image display on the page come from introtext (it's not a intro image) The image is called via HTML in my article (using image manager). I don't use intro image because I want this image to also appear when the article is opened (on it's one). That way, I can't edit com_content because it will remove all the link on all my images, and not only the link of the images displayed on the Tag page (which is what I am trying to do). Thanks for your help! – MagTun Jul 22 '14 at 16:46
  • @FFrewin: I want to remove the link on the images displayed on the Tag page. The link comes from introtext (the article HTML) I gave set it that way because when the article is open, the link on the image redirects to another page. I could remove the link on the image on a articles category page but not on the Tag Page – MagTun Jul 22 '14 at 17:06
1

Okay, after having a better overview of you issue, here is what you need to do to achieve what you want:

Create a template override inside the html folder of your template, for the Tags Component. To do this, create the following folder structure:

/templates/yourtemplate/html/com_tags/tag/

Copy in the above folder the file:

default_items.php from the components/com_tags/views/tag/tmpl folder.

Open this file to edit it. Around the line 80 you will see:

<?php if ($this->params->get('tag_list_show_item_description', 1)) : ?>
    <?php echo $item->event->beforeDisplayContent; ?>           
    <span class="tag-body">
        <?php echo JHtml::_('string.truncate', $item->core_body, $this->params->get('tag_list_item_maximum_characters')); ?>
    </span>
    <?php echo $item->event->afterDisplayContent; ?>

Change it by adding your code before echoing the description text (e.g. before the "tag-body" span):

<?php
$item->core_body =strip_tags( $item->core_body, '<img>');
?>

So you will end with something like below:

    <?php if ($this->params->get('tag_list_show_item_description', 1)) : ?>
    <?php echo $item->event->beforeDisplayContent; ?>
    <?php
        $item->core_body =strip_tags( $item->core_body, '<img>');
    ?>          
    <span class="tag-body">
        <?php echo JHtml::_('string.truncate', $item->core_body, $this->params->get('tag_list_item_maximum_characters')); ?>
    </span>
    <?php echo $item->event->afterDisplayContent; ?>

Initial Answer:

You website is a bit confusing, a bit hard to navigate and there is not a standard way to reach to all kind of content and categories. I also think that there is a bit of confusion in the configuration, as some pages are displaying the tags info, other only the categories and so on.

Furthermore, I was trying to reach one of the articles from that tag list to examine how and why it uses an image in its introtext with link to external websites, but although the images of the articles direct to external websites, the article titles produce a 404 error.

First of all, I believe you should refine the whole configuration of the website and the components. I can't say what exactly you need to do within this answer - you probably might need to hire someone to help you sort this out.

Regarding the issue with the links - I checked also a few other tags and not all tags are having links into their description. This leads me to think that those specific images into the introtext are linking to these external websites.

I think that since you have set the Tags component to display the introtext, it will just use that and will contain any of the markup of the article's introtext.

One way to overcome this, is to use the hide introtext feature of the Content component. Following this approach, you will be creating the same content twice for introtext and fulltext. In the introtext you will be using the image without the link, while in the fulltext you will be able to add your link. Setting Joomla to hide the introtext from the article display, will result to have 2 different block of texts to display for your needs.

The introtext without the links for all blog layouts/ tag lists, article modules etc and the fulltext for the article display.

Or you could use the Joomla Content's images features, from the tab "Images and Links" and set there your intro image.

However keep in mind that the output of each component is also controlled by any possible template overrides for each component.

  • Thanks for this answer and all the advices. I forgot to mention that the website is still under developpement especially the part concerning the tags. We were working on the article this morning so I depublished them and I completely forgot that I gave you the link, but I have republished them so now all the articles on this page : rscmovement.org/en/component/tags/tag/12-cultural-maturity are accessible (just for this tag). Sorry for that. I have use the code in my question to do the similar thing on a category page (keep image of introtext but remove its link), it's working fine. – MagTun Jul 23 '14 at 11:40
  • I need to have the image displayed when the articles are open so I can't use intro /full text image from the tab "Images and Links", and your solution about copying the content is a bit of a headache, especially because the articles are often updated, so it's double job. I have no template override of the com_tag. Maybe I am stubborn but I really want to find a solution based on the the tag component override. – MagTun Jul 23 '14 at 11:41
  • I updated my answer to deal with what you asked. * And yes you are right, your code is the right one to strip out the tags. – FFrewin Jul 23 '14 at 12:33
  • It's working! So great! I can'T believe the time you spent to help me! I very grateful to you! Such a nice person you are! I thank you again for your advice, you can't imagine how precious they are for me, since your a the first professional feed-back we receive. Once again thanks a thousand time! – MagTun Jul 23 '14 at 12:45
1

It sounds to me like you need to build a content plugin (it's quite easy) to strip the tags. See Creating a content plugin, and put your code in the php file. The event that should trigger it is likely the onContentPrepare event, or perhaps onContentBeforeDisplay.

  • Thanks GDP! I don't understand why I am suppose to build a content plugin whereas I could edit the the PHP file. There should somewhere in the php a code that calls the image, but I can't manage to find it! – MagTun Jul 22 '14 at 16:53
  • I suppose itt all roots back to manipulating the output as opposed to changing PHP - personally I like the plugin approach rather than parsing out how it's stored...much more reusable. – GDP Jul 22 '14 at 17:08
  • Thanks for the info and the link. I don't have issue with "intro image" but with images placed in the HTML introtext. – MagTun Jul 23 '14 at 7:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.