Facebook  Twitter 

SMFHacks.com

+- +-

SMFHacks.com

+- User Information

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

+- Forum Stats

Members
Total Members: 12086
Latest: thestuart
New This Month: 8
New This Week: 2
New Today: 2
Stats
Total Posts: 38721
Total Topics: 6821
Most Online Today: 91
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 91
Total: 91

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

0 Members and 1 Guest are viewing this topic.

Offline exit

  • Jr. Member
  • **
  • Posts: 82
    • 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: 14392
    • 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! Also contests/promotions for verified sites.

Offline exit

  • Jr. Member
  • **
  • Posts: 82
    • 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: 14392
    • 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! Also contests/promotions for verified sites.

Offline exit

  • Jr. Member
  • **
  • Posts: 82
    • 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: 14392
    • 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! Also contests/promotions for verified sites.

Offline exit

  • Jr. Member
  • **
  • Posts: 82
    • 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: 14392
    • 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! Also contests/promotions for verified sites.

Offline exit

  • Jr. Member
  • **
  • Posts: 82
    • 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: 14392
    • 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! Also contests/promotions for verified sites.

 

Related Topics

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

+- Recent Topics

SMF Store - Installed, but where is everything? by SMFHacks
April 22, 2018, 08:11:39 pm

Time offset by SMFHacks
April 21, 2018, 12:04:45 pm

Questions about by emilyturner
April 20, 2018, 04:34:17 am

Mass Change for Permissions by Dragon41673
April 17, 2018, 08:42:33 am

not previously loaded by loadMemberData.... by dan4ever
April 17, 2018, 01:53:00 am

Download title by SMFHacks
April 14, 2018, 06:57:02 pm

Responsive theme problems by SMFHacks
March 28, 2018, 12:40:58 pm

Image Scrolling by SMFHacks
March 26, 2018, 01:55:50 pm

error uninstalling contact page 3.2 by SMFHacks
March 26, 2018, 08:11:44 am

Search Tags by SMFHacks
March 25, 2018, 04:29:58 pm

Powered by EzPortal