Facebook  Twitter 

SMFHacks.com

+- +-

SMFHacks.com

+- User Information

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

+- Forum Stats

Members
Total Members: 12208
Latest: Sousbi
New This Month: 16
New This Week: 8
New Today: 0
Stats
Total Posts: 39235
Total Topics: 6905
Most Online Today: 40
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 31
Total: 31

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

0 Members and 1 Guest are viewing this topic.

Offline exit

  • Badge Awards Customer
  • 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: 14644
    • 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

  • Badge Awards Customer
  • 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: 14644
    • 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

  • Badge Awards Customer
  • 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: 14644
    • 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

  • Badge Awards Customer
  • 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: 14644
    • 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

  • Badge Awards Customer
  • 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: 14644
    • 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
5071 Views
Last post September 05, 2007, 03:45:12 am
by Scy
1 Replies
3234 Views
Last post November 15, 2008, 02:03:25 pm
by SMFHacks
2 Replies
3943 Views
Last post November 13, 2010, 03:39:43 pm
by jacci
6 Replies
2591 Views
Last post June 13, 2012, 06:39:37 pm
by BSD2000
1 Replies
1384 Views
Last post February 10, 2013, 12:26:11 pm
by SMFHacks

+- Recent Topics

message editor pro by dan42101
October 19, 2018, 11:26:45 pm

multiple currencies bug by SMFHacks
October 19, 2018, 09:45:49 pm

Looking for ideas for next SMF Classifieds by SMFHacks
October 19, 2018, 04:41:48 pm

Turn off Download Stats? by SMFHacks
October 18, 2018, 12:12:28 pm

KARMA Badge by SMFHacks
October 17, 2018, 11:17:16 pm

remove the boards ? by SMFHacks
October 16, 2018, 03:08:00 pm

Upgraded to pro - some features not working? by SMFHacks
October 16, 2018, 10:21:38 am

SMF lottery mod by SMFHacks
October 13, 2018, 08:02:41 am

Error after adding Russian translation by SMFHacks
October 08, 2018, 04:10:41 pm

Adseller Pro 3.0 Released! by SMFHacks
October 06, 2018, 05:45:42 pm

Powered by EzPortal