Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

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

+- Forum Stats

Members
Total Members: 4267
Latest: ramiroelliot
New This Month: 2
New This Week: 0
New Today: 0
Stats
Total Posts: 43544
Total Topics: 7565
Most Online Today: 70
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 48
Total: 48

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

0 Members and 1 Guest are viewing this topic.

Offline exit

  • Bad Emails DO NOT EMAIL
  • 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: 16563
    • 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

  • Bad Emails DO NOT EMAIL
  • 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: 16563
    • 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

  • Bad Emails DO NOT EMAIL
  • 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: 16563
    • 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

  • Bad Emails DO NOT EMAIL
  • 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: 16563
    • 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

  • Bad Emails DO NOT EMAIL
  • 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: 16563
    • 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
7745 Views
Last post September 05, 2007, 03:45:12 am
by Scy
1 Replies
5720 Views
Last post November 15, 2008, 02:03:25 pm
by SMFHacks
2 Replies
7516 Views
Last post November 13, 2010, 03:39:43 pm
by jacci
6 Replies
4151 Views
Last post June 13, 2012, 06:39:37 pm
by BSD2000
1 Replies
3668 Views
Last post February 10, 2013, 12:26:11 pm
by SMFHacks

+- Recent Topics

Move picture from main gallery to user gallery by Lirorobert
Today at 03:08:26 pm

Gallery Pro reinstalation by Lirorobert
Today at 03:04:50 pm

quoting part of message by Lirorobert
October 04, 2024, 03:21:40 pm

Does SMF Gallery support by SMFHacks
October 02, 2024, 06:14:26 am

Restoring a deleted photo by Monocero
September 28, 2024, 04:12:20 am

Item count on Gallery Tab shows double by SMFHacks
September 26, 2024, 12:59:20 pm

Forum post missing when image over 4000x pixels is uploaded to gallery by Michel68
September 24, 2024, 01:37:17 pm

Setting a photo as invisible by Monocero
September 17, 2024, 02:11:56 pm

Two gallery names by SMFHacks
September 15, 2024, 02:17:49 pm

Bar during the regeneration of miniatures by Monocero
September 15, 2024, 12:35:08 pm

Powered by EzPortal