Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

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

+- Forum Stats

Members
Total Members: 4255
Latest: andreios
New This Month: 3
New This Week: 1
New Today: 0
Stats
Total Posts: 43259
Total Topics: 7518
Most Online Today: 177
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 174
Total: 174

Author Topic: category img if there is no pictures  (Read 11923 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: 16436
    • 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: 16436
    • 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: 16436
    • 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: 16436
    • 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: 16436
    • 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
7600 Views
Last post September 05, 2007, 03:45:12 am
by Scy
1 Replies
5586 Views
Last post November 15, 2008, 02:03:25 pm
by SMFHacks
2 Replies
7282 Views
Last post November 13, 2010, 03:39:43 pm
by jacci
6 Replies
3959 Views
Last post June 13, 2012, 06:39:37 pm
by BSD2000
1 Replies
3548 Views
Last post February 10, 2013, 12:26:11 pm
by SMFHacks

+- Recent Topics

No thumbnails on new uploads by SMFHacks
March 27, 2024, 02:10:41 pm

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

an idea for new mod (( content type with different display )) by SMFHacks
February 27, 2024, 01:36:27 pm

[Mod] RSS Feed Poster by SMFHacks
February 27, 2024, 11:57:18 am

find duplicate pictures by fvlog19
February 14, 2024, 02:22:40 pm

Error uploading video. by SMFHacks
February 08, 2024, 02:04:16 pm

Gallery icon as last added image by fvlog19
February 01, 2024, 01:04:56 pm

Powered by EzPortal