Only first image for swipe script
#1 19-11-2015 
Hi Lee, do you know how to get only the first image of a thread and add it to swipe script?

The key of the first image is "portalimg" and the other 6 images of each thread have other name keys (in total 7 images for thread, it's a forum of review).

With this code:

Code:
$query = $db->query("
        SELECT a.*, t.*, td.*
        FROM ".TABLE_PREFIX."threads t
        LEFT JOIN ".TABLE_PREFIX."xtattachments a ON (a.tid=t.tid)
        LEFT JOIN ".TABLE_PREFIX."threadfields_data td ON (td.tid=t.tid)
        WHERE t.visible='1' AND td.portale='show' AND t.fid IN ('81')
        ORDER BY t.dateline DESC
        LIMIT 0, 10
");

        while($portal_coll = $db->fetch_array($query))
        {
            $portal_coll_title = htmlspecialchars_uni($portal_coll['subject']);
            $portal_coll_postlink = get_thread_link(intval($portal_coll['tid']));
            $portal_coll_att_thumb = xthreads_get_xta_url($portalimg).'/thumb400x400';
            eval("\$portal_coll_gallery_gallery .= \"".$templates->get("portal_coll_gallery_gallery")."\";");
        }
        
        eval("\$portal_coll_gallery = \"".$templates->get("portal_coll_gallery")."\";");

I have tried with:

$portal_coll_att_thumb = xthreads_get_xta_url($portalimg).'/thumb400x400';
$portal_coll_att_thumb = xthreads_get_xta_url($portalimg);
$portal_coll_att_thumb = xthreads_get_xta_url($portal_coll['portalimg']);
$portal_coll_att_thumb = xthreads_get_xta_url($portal_coll);

But always 3-4 results, based on each image in thread Sad instead of an only image for thread.

How can I do? On Leefish you have only an image in slideshow also if there are more images in thread.

Thank you in advance

#2 20-11-2015 
Deb - hugely busy today. I will look on Saturday Smile

Your WHERE does not say where it is a portal img (you need the key of the field) - then it should get just that image. Right now your query returns all images.

#3 20-11-2015 
Ok Lee. I have tried with

WHERE t.visible='1' AND td.portale='show' AND td.portalimg AND t.fid IN ('81') but nothing Sad

The key is portalimg

#4 20-11-2015 
Ok, try this:

Code:
$query = $db->query("
            SELECT a.aid, a.attachname, a.filename, a.field, t.*
            FROM ".TABLE_PREFIX."xtattachments a
            LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=a.tid)
                        LEFT JOIN ".TABLE_PREFIX."threadfields_data td ON (td.tid=a.tid)
            WHERE t.visible=1 AND td.portale='show' AND a.field='portalimg' AND t.fid IN ('81')
            ORDER BY t.dateline DESC
            LIMIT 0,10
");

#5 20-11-2015 
Leeeeeeeeee, works!!!

Code:
$query = $db->query("
            SELECT a.*, t.*, td.*
            FROM ".TABLE_PREFIX."threads t
            LEFT JOIN ".TABLE_PREFIX."xtattachments a ON (a.tid=t.tid)
            LEFT JOIN ".TABLE_PREFIX."threadfields_data td ON (td.tid=t.tid)
            WHERE t.visible=1 AND td.portale='show' AND a.field='portalimg' AND t.fid IN ('81')
            ORDER BY t.dateline DESC
            LIMIT 0, 10
");

        while($portal_coll = $db->fetch_array($query))
        {
            $portal_coll_title = htmlspecialchars_uni($portal_coll['subject']);
            $portal_coll_postlink = get_thread_link(intval($portal_coll['tid']));
            $portal_coll_att_thumb = xthreads_get_xta_url($portal_coll).'/thumb400x400';
            eval("\$portal_coll_gallery_gallery .= \"".$templates->get("portal_coll_gallery_gallery")."\";");
        }
        
        eval("\$portal_coll_gallery = \"".$templates->get("portal_coll_gallery")."\";");

and in template: <img src="{$mybb->settings['bburl']}/{$portal_coll_att_thumb} alt="{$portal_coll_title}" />


I tried with only: SELECT a.aid, a.attachname, a.filename, a.field, t.*

but I had always only like:

/xthreads_attach.php/5578_1395870751_d20f49d7/namefile.jpg/thumb400x400

missed always something in the file and I didn't see the image.


So, for select a specific thread field need: a.field='fieldname'

Thank you very much Big Grin

#6 21-11-2015 
You only need to use the a.field if its an attachment; otherwise threadfields data table has all the info Smile

#7 21-11-2015 
For attachment means image uploaded with xthreads?

So:

- If it's Xthreads file image upload -> a.field
- If it's Xthreads normal data (textbox, URL, checkbox etc) -> td='namefield' ? or nothing, only use in the template {$GLOBALS['threadfields']['key of field']}
- If it's Xthread specific condition for normal data -> td.fieldname='condition to filter result' (for example my 'show')

#8 21-11-2015 
Exactly Deb Smile Only for attachments (uploaded images/files) do you use the a.field Smile

#9 21-11-2015 
Thank you Lee Big Grin too many things to learn on Xthreads



Sorry, that is a members only option