Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+- Forum Stats

Members
Total Members: 4257
Latest: Alex998.
New This Month: 1
New This Week: 0
New Today: 0
Stats
Total Posts: 43295
Total Topics: 7523
Most Online Today: 175
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 166
Total: 166

Author Topic: category img if there is no pictures  (Read 11945 times)

0 Members and 1 Guest are viewing this topic.

Offline exit

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
category img if there is no pictures
« on: October 02, 2016, 12:05:16 pm »
I'm adding the $row['ID_CAT'] to get he category ID, but I'm missing something and it's not retrieving the category ID, any ideas?


Code: [Select]
if (!empty($row['primaryID_PICTURE']))
{

echo '<a href="', $scripturl, '?action=classifieds;sa=view;id=', $row['ID_LISTING'], '"><img src="', $modSettings['class_url'], $row['thumbfilename'], '" alt="" /></a>';

}
else
{


echo '<a href="', $scripturl, '?action=classifieds;sa=view;id=', $row['ID_LISTING'], '"><img src="' . $modSettings['class_url'] . 'catimgs/' . $row['ID_CAT'] . '.png" /></a>';
}
« Last Edit: October 02, 2016, 12:12:32 pm by exit »

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16452
    • View Profile
Re: category img if there is no pictures
« Reply #1 on: October 02, 2016, 12:42:56 pm »
You would need to check that select statement in the SQL also includes ID_CAT in the list of fields it is returning.
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline exit

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
Re: category img if there is no pictures
« Reply #2 on: October 02, 2016, 12:45:23 pm »
Thanks for the reply, I see, but I don't have one in this fuction...

Code: [Select]
function ClassifiedsShowListingsRow($row,$g_manage,$showCheckAll = false)
{
global $scripturl, $modSettings, $smcFunc, $context, $txt, $settings, $subcats_linktree, $options, $user_info, $memberContext;


if (!isset($context['noprice']))
$context['noprice'] = 0;

       
  $styleClass = ($row['featuredlisting'] ?  'windowbg' : 'windowbg2');
 
  if (isset($row['approved']) && $row['approved'] == 0)
    $styleClass = 'approvetbg2';



echo'
<div class="row results">';
       $memCommID = $row['ID_MEMBER'];
    loadMemberData($memCommID);
loadMemberContext($memCommID);

echo'
<div class="col-md-4 col-sm-4 col-xs-12 userx"><a href="', $scripturl, '?action=profile;u=', $row['ID_MEMBER'], '">', $memberContext[$memCommID]['avatar']['image'], '</a>
<a href="', $scripturl, '?action=profile;u=', $row['ID_MEMBER'], '">', $row['real_name'], '</a>

</div>';


echo'
<div class="col-md-2 col-sm-2 col-xs-4">';






echo '<div class="market-pic">';

if (!empty($row['primaryID_PICTURE']))
{

echo '<a href="', $scripturl, '?action=classifieds;sa=view;id=', $row['ID_LISTING'], '"><img src="', $modSettings['class_url'], $row['thumbfilename'], '" alt="" /></a>';

}
else
{



echo '<a href="', $scripturl, '?action=classifieds;sa=view;id=', $row['ID_LISTING'], '"><img src="' . $modSettings['class_url'] . 'catimgs/' . $row['ID_CAT'] . '.png" /></a>';
}

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16452
    • View Profile
Re: category img if there is no pictures
« Reply #3 on: October 02, 2016, 12:47:42 pm »
You would have to find instances of the classified system calling ClassifiedsShowListingsRow(
Which is probably in the template file then alter the database queries before.
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline exit

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
Re: category img if there is no pictures
« Reply #4 on: October 02, 2016, 01:06:24 pm »
I'm trying hard, but my php knowledge is limited. Can you be a bit more specific on how to get the $row['ID_CAT'] inside the function ClassifiedsShowListingsRow

thank a lot

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16452
    • View Profile
Re: category img if there is no pictures
« Reply #5 on: October 02, 2016, 01:18:49 pm »
Example in classified2.template.php
Orginal code
Code: [Select]

// Show the classifieds
$dbresult = $smcFunc['db_query']('', "
SELECT
i.ID_LISTING, i.title, i.currency, i.primaryID_PICTURE, p.remotefilename,
p.thumbfilename, i.datelisted, i.commenttotal, i.currentbid,
i.listingstatus,i.featuredlisting,i.totalbids, i.views,i.expiredate,
i.ID_MEMBER,m.real_name, i.is_auction, i.featuredlisting, i.statuscolor, i.statustext, mg.online_color,
            i.approved 
FROM {db_prefix}class_listing as i 
LEFT JOIN {db_prefix}class_listing_pic as p ON (i.primaryID_PICTURE = p.ID_PICTURE)
LEFT JOIN {db_prefix}members as m ON (i.ID_MEMBER = m.ID_MEMBER)
        LEFT JOIN {db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(m.ID_GROUP = 0, m.ID_POST_GROUP, m.ID_GROUP))
WHERE  i.removed = 0 AND i.ID_CAT = $cat $listingwhereClause
ORDER BY $sortby $orderby LIMIT $context[start]," . $modSettings['class_set_listings_per_page']);

while($row = $smcFunc['db_fetch_assoc']($dbresult))
{
               if ($row['approved'] == 0)
               {
                $row['title'] = $txt['class_txt_waitingforapproval'] . ' - ' . $row['title'];

               }

$fields = array();

foreach($customFields as $field)
{
// Show Custom Fields
$result = $smcFunc['db_query']('', "
SELECT
f.title, d.value
FROM ({db_prefix}class_custom_field as f,{db_prefix}class_custom_field_data as d)
WHERE f.ID_CAT = $cat AND d.ID_CUSTOM = f.ID_CUSTOM AND d.ID_LISTING = " . $row['ID_LISTING'] .  " AND f.ID_CUSTOM = $field");
$row4 = $smcFunc['db_fetch_assoc']($result);

$fields[] = array("ID_CUSTOM" => $field,"value" => $row4['value'] );



}

$row['CUSTOMFIELDS'] = $fields;



ClassifiedsShowListingsRow($row,$g_manage,true);
}
Changed to
Code: [Select]

// Show the classifieds
$dbresult = $smcFunc['db_query']('', "
SELECT
i.ID_LISTING, i.title, i.currency, i.primaryID_PICTURE, p.remotefilename,
p.thumbfilename, i.datelisted, i.commenttotal, i.currentbid,
i.listingstatus,i.featuredlisting,i.totalbids, i.views,i.expiredate,
i.ID_MEMBER,m.real_name, i.is_auction, i.featuredlisting, i.statuscolor, i.statustext, mg.online_color,
            i.approved, i.ID_CAT 
FROM {db_prefix}class_listing as i 
LEFT JOIN {db_prefix}class_listing_pic as p ON (i.primaryID_PICTURE = p.ID_PICTURE)
LEFT JOIN {db_prefix}members as m ON (i.ID_MEMBER = m.ID_MEMBER)
        LEFT JOIN {db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(m.ID_GROUP = 0, m.ID_POST_GROUP, m.ID_GROUP))
WHERE  i.removed = 0 AND i.ID_CAT = $cat $listingwhereClause
ORDER BY $sortby $orderby LIMIT $context[start]," . $modSettings['class_set_listings_per_page']);

while($row = $smcFunc['db_fetch_assoc']($dbresult))
{
               if ($row['approved'] == 0)
               {
                $row['title'] = $txt['class_txt_waitingforapproval'] . ' - ' . $row['title'];

               }

$fields = array();

foreach($customFields as $field)
{
// Show Custom Fields
$result = $smcFunc['db_query']('', "
SELECT
f.title, d.value
FROM ({db_prefix}class_custom_field as f,{db_prefix}class_custom_field_data as d)
WHERE f.ID_CAT = $cat AND d.ID_CUSTOM = f.ID_CUSTOM AND d.ID_LISTING = " . $row['ID_LISTING'] .  " AND f.ID_CUSTOM = $field");
$row4 = $smcFunc['db_fetch_assoc']($result);

$fields[] = array("ID_CUSTOM" => $field,"value" => $row4['value'] );



}

$row['CUSTOMFIELDS'] = $fields;



ClassifiedsShowListingsRow($row,$g_manage,true);
}
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline exit

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
Re: category img if there is no pictures
« Reply #6 on: October 02, 2016, 01:28:00 pm »
Thanks, interesting... Now it works, but just inside the categories not on the simple list template. Any idea?

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16452
    • View Profile
Re: category img if there is no pictures
« Reply #7 on: October 02, 2016, 01:32:24 pm »
There are multiple places in the code where ID_CAT needs to be added to in the sql
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline exit

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
Re: category img if there is no pictures
« Reply #8 on: October 02, 2016, 01:59:09 pm »
Thanks a lot, added the ID_CAT to one more place and it's working now!

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16452
    • View Profile
Re: category img if there is no pictures
« Reply #9 on: October 02, 2016, 02:00:00 pm »
Glad to help.
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

 

Related Topics

  Subject / Started by Replies Last post
3 Replies
7616 Views
Last post September 05, 2007, 03:45:12 am
by Scy
1 Replies
5616 Views
Last post November 15, 2008, 02:03:25 pm
by SMFHacks
2 Replies
7330 Views
Last post November 13, 2010, 03:39:43 pm
by jacci
6 Replies
3977 Views
Last post June 13, 2012, 06:39:37 pm
by BSD2000
1 Replies
3575 Views
Last post February 10, 2013, 12:26:11 pm
by SMFHacks

+- Recent Topics

Please Help! by SMFHacks
April 17, 2024, 08:04:55 am

Rate own images by fvlog19
April 11, 2024, 10:56:53 am

Tidy Child Boards on 2.1.4 by SMFHacks
April 04, 2024, 03:54:12 pm

Problems SMF 2.0.19 > 2.1.4 SMF Gallery Pro - Recents Images to overall header by Michel68
March 30, 2024, 12:41:08 pm

Can't DROP 'id_member'; check that column/key exists Datei: by SMFHacks
March 30, 2024, 11:58:20 am

No thumbnails on new uploads by Tonyvic
March 29, 2024, 06:26:18 am

Display the Contact Page for guests by SMFHacks
March 27, 2024, 10:55:43 am

is it possible to add support for odysee.com by fvlog19
March 21, 2024, 08:47:51 am

Request for admin notification by davejo
March 10, 2024, 01:31:59 am

I need help with torrent upload by Ineedsmfhelp
March 09, 2024, 10:01:13 pm

Powered by EzPortal