Images of Xthreads on index.php (portal)
#1 10-11-2013 
Hi Lee, I have always a problem with images of Xthreads Sad

On site.com/index.php (a portal page) images don't work in "Latest posts".


In index.php the code is:

Code:
// Latest forum discussions2
if($mybb->settings['portal_showdiscussions'] != 0 && $mybb->settings['portal_showdiscussionsnum'])
{
        $altbg = alt_trow();
        $threadlist = '';
        $piccount=4;
        $query = $db->query("
            SELECT a.updatetime, a.uploadtime, a.attachname, a.filename, a.thumbs, t.*
            FROM ".TABLE_PREFIX."xtattachments a
            LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=a.tid)
            WHERE t.visible=1 AND a.thumbs!=' ' AND t.showinportal='1' AND t.closed NOT LIKE 'moved|%' AND t.fid IN ('128')
            GROUP BY a.tid
            ORDER BY t.dateline DESC
            LIMIT 0, $piccount
        ");        
                
        while($thread = $db->fetch_array($query))
        {
                $forumpermissions[$thread['fid']] = forum_permissions($thread['fid']);

                // Make sure we can view this thread
                if($forumpermissions[$thread['fid']]['canview'] == 0 || $forumpermissions[$thread['fid']]['canviewthreads'] == 0 || $forumpermissions[$thread['fid']]['canonlyviewownthreads'] == 1 && $thread['uid'] != $mybb->user['uid'])
                {
                        continue;
                }

                $lastpostdate = my_date($mybb->settings['dateformat'], $thread['lastpost']);
                $lastposttime = my_date($mybb->settings['timeformat'], $thread['lastpost']);
                // Don't link to guest's profiles (they have no profile).
                if($thread['lastposteruid'] == 0)
                {
                        $lastposterlink = $thread['lastposter'];
                }
                else
                {
                        $lastposterlink = build_profile_link($thread['lastposter'], $thread['lastposteruid']);
                }
                if(my_strlen($thread['subject']) > 25)
                {
                        $thread['subject'] = my_substr($thread['subject'], 0, 25) . "...";
                }
                $thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
                $thread['threadlink'] = get_thread_link($thread['tid']);
                $thread['lastpostlink'] = get_thread_link($thread['tid'], 0, "lastpost");
                eval("\$threadlist .= \"".$templates->get("portal_latestthreads_thread2")."\";");
                $altbg = alt_trow();
        }
        if($threadlist)
        {
                // Show the table only if there are threads
                eval("\$latestthreads2 = \"".$templates->get("portal_latestthreads")."\";");
        }
}


portal_latestthreads2

Code:
<div class="thead"><strong>{$lang->latest_threads}</strong></div>
<div>
{$threadlist}
</div>
<br />


portal_latestthreads_thread2

Code:
<div class="custhovfordisplay" style="padding: 4px 0px 7px 0px;">
<a href="{$mybb->settings['bburl']}/{$thread['threadlink']}" title="{$thread['subject']}"><strong>{$thread['subject']}</strong></a></div>

<div class="sfondogrigio">

<div class="float_left">
<div align="center" style="height:80px;">
<a href="{$thread['threadlink']}">
<img src="{$GLOBALS['threadfields']['portalimg']['url']}/thumb80x80" width="{$GLOBALS['threadfields']['portalimg']['thumbs']['80x80']['w']}" height="{$GLOBALS['threadfields']['portalimg']['thumbs']['80x80']['h']}" alt="{$thread['subject']}" class="attachment" />
</a>
</div>
</div>

<div class="textright">
<ul>
<li><a href="{$thread['lastpostlink']}">Risposta di: </a>{$lastposterlink}</li>
<li>{$lastpostdate} alle {$lastposttime}</li>
</ul>
</div>

</div>


Zinga Burga answered me:

Quote:You're never evaluating $threadfields anywhere. Of course it won't work - your PHP code doesn't even have a mention of $threadfields.

The general gist of things is to have something like

Code:
$url = get_xta_url($thread);

and use {$url} in templates, although that doesn't solve everything.

And stop..I need an input Sad I have read all files of Xthreads plugin and Google, to find how works this $threadfields but nothing Sad and what's {$url} ? url isn't image I think

0
#2 11-11-2013 
Yea, what he means is you cant use threadfields in the template because you are not using threadfields in the php, so what you need to do is tell the php where the image url is. That is how the galleries work to get the image.

Look at the list of variables in any of my gallery plugins and you will see that is missing from your code.

0
#3 11-11-2013 
Bof Lee, I have tried in this way:

Code:
$thread['subject'] = htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
$thread['threadlink'] = get_thread_link($thread['tid']);
$thread['lastpostlink'] = get_thread_link($thread['tid'], 0, "lastpost");
$thumb = xthreads_get_xta_url($thread).'/thumb80x80';
$thread.="<a href='{$threadlink}'><img src='forum/{$thumb}' alt='{$thread['subject']}' title='{$thread['subject']}' /></a>";
eval("\$threadlist .= \"".$templates->get("portal_latestthreads_thread2")."\";");
$altbg = alt_trow();

with:

Code:
$thread.="<a href='{$threadlink}'><img src='forum/{$thumb}' alt='{$thread['subject']}' title='{$thread['subject']}' /></a>";

the result in index page in portal_latestthreads_thread2 is:

Code:
<a href=""><img src="forum/xthreads_attach.php/_1383730695_173b92c6/lacosmeticabeauty.JPG/thumb80x80" alt="" title=""></a>

and in template I have:

Code:
<a href="{$threadlink}"><img src="forum/{$thumb}" alt="{$thread['subject']}" title="{$thread['subject']}" /></a>



A href doesn't work (and also image, link is wrong but attachname is correct: "lacosmeticabeauty.JPG"), maybe because $thread.=" isn't right..I have tried also with

Code:
$thread_att_thumb.="<a href='{$threadlink}'><img src='forum/{$thumb}' alt='{$threadtitle}' title='{$threadtitle}' /></a>";


and same problem Sad

0
#4 12-11-2013 
Ok, finally solved in chat; the img variable was never declared in the while loop and was excluded in the original query.

Both fixed and all ok.

1
#5 12-11-2013 
Thank you Lee! More or less I start to understand this query..but I still have a lot to study it Sad

I understand the language, just do not understand how to put it all together at the code level Big Grin

0
#6 12-11-2013 
Hi, in the cPanel I have:

Quote:CloudFlare
CloudFlare accelerates and protects any website online. On average, a website on CloudFlare:

Loads 30% faster
Uses 60% less bandwidth
Has 65% fewer requests
And, is way more secure.
Learn More ...

Who can use CloudFlare:
CloudFlare is suitable for all websites, including dynamic websites. Signing up takes less than two minutes. If you do not like the service, it takes even less time to un-signup.
Note: This service is a collaboration between CloudFlare and your web hosting provider. We encourage you to send any bug reports to xx.
Sign up for CloudFlare now

What happens if I add the email?

0
#7 12-11-2013 
You are signed up and have the option to change the settiings to use Cloudflare.

1
#8 13-11-2013 
Cloudflare activated :x tomorrow I'll see if site is still on the Earth Big Grin

1
#9 13-11-2013 
Boh..seems nothing differences..mah

Maybe CloudFlare is on www and "I have naked domain", if I have understand well

0
#10 18-01-2014 
Lee I have deleted index.php page, while I moved the site in new hosting Sad

Anyway maybe is more easy add xthreads image in the annoucements.

So:

Code:
$query = $db->query("
        SELECT p.pid, p.message, p.tid, p.smilieoff
        FROM ".TABLE_PREFIX."posts p
        LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
        WHERE t.fid IN (".$announcementsfids.") AND t.visible='1' AND t.closed NOT LIKE 'moved|%' AND t.firstpost=p.pid
        ORDER BY t.dateline DESC
        LIMIT 0, {$numannouncements}"
    );
    while($getid = $db->fetch_array($query))
    {

If I remember well (no Big Grin ):

Code:
$query = $db->query("
        SELECT a.*, p.pid, p.message, p.tid, p.smilieoff
        FROM ".TABLE_PREFIX."a
FROM ".TABLE_PREFIX."posts p
        LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
        WHERE t.fid IN (".$announcementsfids.") AND t.visible='1' AND t.closed NOT LIKE 'moved|%' AND t.firstpost=p.pid
        ORDER BY t.dateline DESC
        LIMIT 0, {$numannouncements}"
    );
$url = get_xta_url($thread);
    {

I don't know Sad only show xthreads image from thread in "/forum" to "site.com/index.php" (portal template)




EDIT: nothing Lee, sorry, resolved, I had to only add {$mybb->settings['bburl']} Sad
(This post was last modified: 19-01-2014 12:27 AM by noiredeb.)

1


Sorry, that is a members only option