Mel VIP
Total posts: 126
08 Nov 2013 19:35

In list view if the thumbnail is clicked it shows the full image.

How can I make it so if the thumbnail is clicked in list view it takes the person to the full article view?

Last Modified: 02 Mar 2014


pepperstreet VIP
Total posts: 3,837
09 Nov 2013 20:40

As far as I know, this is the default behavior. Just make sure the following lightbox parameter is turned** OFF**. This adds a link to full-view automatically.

(This applies to both image-sizes: original AND resized! The parameter label mentions "original" only... this sounds a bit confusing.

Edit Image field -> List view parameters


Mel VIP
Total posts: 126
10 Nov 2013 16:39

I'm sorry I didn't explain myself enough. I would like to make the thumbnail link to the full article. At the moment, when the thumbnail is clicked it goes to the full image, not the full article.


Mel VIP
Total posts: 126
10 Nov 2013 22:24

For me, instead of showing the full image in the lightbox it shows the full image on a white page with no title etc, not the article page.


Mel VIP
Total posts: 126
11 Nov 2013 18:33

I see my problem now. I am using a Section I named ‘images’ to upload and store photos. Then using parent/child fields I am able to insert and re-use the same photos in articles in a different section. In the photos store section the article has everything switched off so that only the image can be seen – nothing else.

So when in list view and a thumbnail is clicked it takes the user to the image article (in the image store section), not to the article the image is being displayed in.


Sackgesicht VIP
Total posts: 1,636
11 Nov 2013 18:58

A solution would be a customized list template.

See this article here how to get the record url and modify existing templates.

<?php echo JRoute::_($item->url);?>

Mel VIP
Total posts: 126
12 Nov 2013 20:19

I do not know php but below is my attempt to make the image a link to the article page. From the tutorial and my template, below is the code to display the image field. I used html to make the "echo result" a link – but it doesn’t work. It still goes to the wrong article. Can anyone help me here?


<?php if(isset($item->fields_by_id[$img_field])): ?> <a href="/<?php echo JRoute::_($item->url);?>"><?php echo $item->fields_by_id[$img_field]->result; ?></a> <?php endif; ?>

Sergey
Total posts: 13,748
13 Nov 2013 01:18

Image field create link to article full view automatically if lightbox is turned off.


Mel VIP
Total posts: 126
13 Nov 2013 03:38

Hi Sergey. I think you missed my explanation of how I'm using the image field in a different section to store and re-use images:

I see my problem now. I am using a Section I named ‘images’ to upload and store photos. Then using parent/child fields I am able to insert and re-use the same photos in articles in a different section. In the photos store section the article has everything switched off so that only the image can be seen – nothing else.

So when in list view and a thumbnail is clicked it takes the user to the image article (in the image store section), not to the article the image is being displayed in.


Sergey
Total posts: 13,748
13 Nov 2013 23:17

Now I see your point. it is impossible to do what you want. When you in images section to want article to redirect on image click? What if there are 5 articles with this image? What article link to insert?

If you only want to solve problem of reusing same images, use image manager as means of image select in image field directly in child records. Then you will be using the same image on the disk.


Sackgesicht VIP
Total posts: 1,636
14 Nov 2013 00:04

It still goes to the wrong article. Can anyone help me here?

Mel, if you use the default list template, make a copy of it and replace in line 227 the following part

if(isset($item->fields_by_key[$field->key]->result)) echo $item->fields_by_key[$field->key]->result ;

with

 if(isset($item->fields_by_key[$field->key]->result)) 

 {

     if($field->id == "TYPE_HERE_YOUR_FIELD_ID"){

        ?><a  href="/<?php echo JRoute::_($item->url);?>">

            <?php echo $item->fields_by_key[$field->key]->result ;?>

        </a><?php

     }

     else {

         echo $item->fields_by_key[$field->key]->result ;

     }

 }

Replace the TYPE_HERE_YOUR_FIELD_ID with the actual field_id of your relation field. You can get it from the field listing under the TYPE definition on the right side.

I have not tried the code, it is just based on the assumption, that a hyperlink with the article link surrounding your picture will open the article view.

Maybe it is worth a try.


Sergey
Total posts: 13,748
14 Nov 2013 10:56

I am not sure the suggestion is correct. As I understand there are 2 types and sections. Type PICTURE and type ARTICLE. Type picture have image field. Then in article you select as children pictures. This way you can use the same pictures in few articles.

Now when you are in pictures section and see list of the pictures Mel whats that click on the picture open records of ARTICLE type to which this picture is attached as child.


Sackgesicht VIP
Total posts: 1,636
14 Nov 2013 13:32

Sergey,

Now when you are in pictures section and see list of the pictures Mel whats that click on the picture open records of ARTICLE type to which this picture is attached as child.

in my understanding as stated in his posting

Now when you are in pictures section and see list of the pictures Mel whats that click on the picture open records of ARTICLE type to which this picture is attached as child.

So when in list view and a thumbnail is clicked it takes the user to the image article (in the image store section), not to the article the image is being displayed in.

he wants the ARTICLE containing the image to open ...


Mel VIP
Total posts: 126
14 Nov 2013 17:28

Sackgesicht & Pepperstreet are right. In list view, when I click the thumbnail, it needs to take me to the full article in the articles section - not the full image in the image storage section.

Sackgesicht the code doesn’t work, I get some parse errors. Also I could only find the code to replace in line 460 of default-list-default.php and line 988 of default-list-table.php

Also I am using advanced templates 1.7 by 'andiamine' for list view.


Sackgesicht VIP
Total posts: 1,636
14 Nov 2013 18:25

Sackgesicht the code doesn’t work, I get some parse errors.

Mel,

I just tried it here and it is working.

Try the attached default list template and change in line 231 the "2" to whatever your field_id is ...

if($field->id == "2"){

Mel VIP
Total posts: 126
15 Nov 2013 22:35

Hi Sackgesicht. Thanks for your help but it just doesnt work for me using your template either.

But I did get it to work by removing the link code in the image field (fields - > image -> output -> list.php). I removed the code below and then your custom template worked just fine.

<?php else:?>

    <a href="/<?php echo $record->url;?>">

Thanks again for your help. I really appreciate it.


Sackgesicht VIP
Total posts: 1,636
15 Nov 2013 23:13

Mel,

glad you finally achieved what you wanted ... :D


pepperstreet VIP
Total posts: 3,837
16 Nov 2013 07:05

Two possible improvements are still in my mind:

1.) Selecting child image in modal window with thumbnail

2.) General feature for Relations field: Adding new child during parent submission! Only working after SAVE/APPLY button. (Comparable to J! core submnission form, where selectbox "order" appears after save operation)

Powered by Cobalt