SMFHacks.com

SMF Classifieds => Support => Topic started by: ajac63 on May 16, 2019, 10:20:54 am

Title: About Layout Options
Post by: ajac63 on May 16, 2019, 10:20:54 am
What do I have to do in Layout Settings to enable three rows of four categories?  So, as follows:
Category 01  Category 02  Category 03  Category 04
Category 05  Category 06  Category 07  Category 08
Category 09  Category 10  Category 11  Category 12

The set-up option I went with is where you have the 'Classifieds' link at the top of the forum enabling visitors to get to the classifieds section that way.

Thanks if anyone can help.
Title: Re: About Layout Options
Post by: ajac63 on May 17, 2019, 12:31:50 am
Can someone please answer the thread.  Layout Options isn't allowing me to do what I expected.  I've paid for this...
Title: Re: About Layout Options
Post by: SMFHacks on May 17, 2019, 11:09:22 am
There are currently two layout options.
The default option is the categories are vertical rows the description, number of listings, image of classifieds category

The second option is found admin -> layout settings -> “Use simple main layout with recent listings as the focus”  which focuses on listings and puts classifieds categories as a small list on the left side.

For the changes you need would require you to make edits to themes/default/classfieds2.template.php function template_classifiedsmain  You would need to change the loop structure to make each category title inside a td in the table tag then stop after x amount of and add the closing tr tag. I do that in a few spots in the code as reference.

Title: Re: About Layout Options
Post by: ajac63 on May 18, 2019, 07:22:19 am
Many thanks for your help and sorry for late reply...  I think I was expecting some sort of wysiwyg layout editor - I guess that was wishful thinking ::). But I'm sure I'll work it out.
Title: Re: About Layout Options
Post by: ajac63 on May 20, 2019, 04:11:22 pm
Right, I'm getting there, but I now have one long column of 12 categories on the let-hand side, so I'm thinking I will have to go with your suggestion of - 'You would need to change the loop structure to make each category title inside a td in the table tag then stop after x amount of and add the closing tr tag.'

Thing is my html knowhow is not great, so if someone could show me the actual lines of html code, that would be great.  Thanks.
Title: Re: About Layout Options
Post by: SMFHacks on May 20, 2019, 05:00:15 pm
Which layout setting are you using right now?
Title: Re: About Layout Options
Post by: ajac63 on May 21, 2019, 03:14:56 pm
Many thanks.  I have 'simple layout settings...' deselected and then after that I also deselected any option to do with auctions as I only want straight listings.
See attached image showing one large column on the left.[attachimg=2]
-
BTW - why am I not authorised to view attachments?[attach=3]
Title: Re: About Layout Options
Post by: SMFHacks on May 21, 2019, 04:33:45 pm
To access downloads/attachments enter your license key under https://www.smfhacks.com/index.php?action=license
Title: Re: About Layout Options
Post by: ajac63 on May 21, 2019, 06:41:50 pm
Thanks, that seemed to work.  After a browser refresh anyway...  So, what are the lines of html I need to use.
Title: Re: About Layout Options
Post by: SMFHacks on May 21, 2019, 09:21:59 pm
Change these in classifieds2.template.php
Find
Code: [Select]

while($row = $smcFunc['db_fetch_assoc']($dbresult))
{

$totallistings  = Classifieds_GetListingTotals($row['ID_CAT']);

echo '<tr>';

if($row['imageurl'] == '' && $row['imagefilename'] == '')
echo '<td colspan="2" class="windowbg"><a href="' . $scripturl . '?action=classifieds;cat=' . $row['ID_CAT'] . '">' . parse_bbc($row['title']) . '</a> ' . (!empty($modSettings['class_showrss_bycat']) ? '<a href="' . $scripturl . '?action=classifieds;sa=rss;cat=' . $row['ID_CAT'] . ';type=recent"><img src="' . $modSettings['class_url'] . 'rss.png" alt="rss" /></a>' : '') . '</td>
<td class="windowbg2">' . parse_bbc($row['description']) . '</td>';
else
{
if($row['imagefilename'] == '')
echo '<td class="windowbg2"><a href="' . $scripturl . '?action=classifieds;cat=' . $row['ID_CAT'] . '"><img src="' . $row['imageurl'] . '" border="0" alt=""  /></a></td>';
else
echo '<td class="windowbg2"><a href="' . $scripturl . '?action=classifieds;cat=' . $row['ID_CAT'] . '"><img src="' . $modSettings['class_url'] . 'catimgs/' . $row['imagefilename'] . '" border="0" alt=""  /></a></td>';


echo '<td class="windowbg"><a href="' . $scripturl . '?action=classifieds;cat=' . $row['ID_CAT'] . '">' . parse_bbc($row['title']) . '</a> ' . (!empty($modSettings['class_showrss_bycat']) ? '<a href="' . $scripturl . '?action=classifieds;sa=rss;cat=' . $row['ID_CAT'] . ';type=recent"><img src="' . $modSettings['class_url'] . 'rss.png" alt="rss" /></a>' : '') . '</td>
<td class="windowbg2">' . parse_bbc($row['description']) . '</td>';
}



// Show total listings in the category
echo '<td align="center" class="windowbg">', $totallistings, '</td>';

// Show Last Post
if (!empty($modSettings['class_set_show_cat_latest_listings']))
{
echo '<td class="windowbg">';
if (!empty($row['ID_LISTING']))
{

echo '<span class="smalltext">' .  $txt['class_last_post'], ' <a href="',$scripturl,'?action=profile;u=',$row['ID_MEMBER'],'"' . (!empty($row['online_color']) ? ' style="color: ' . $row['online_color'] . ';" ' :'' ) . '>',$row['real_name'],'</a><br />',

'<a href="' . $scripturl . '?action=classifieds;sa=view;id=',$row['ID_LISTING'],'">',shorten_subject($row['listingtitle'], 24) . '</a><br />',$txt['class_txt_on'],timeformat($row['datelisted']) . '</span>';
}

echo '</td>';
}


// Show Edit Delete and Order category
if ($g_manage)
{
echo '
<td class="windowbg2"><a href="' . $scripturl . '?action=classifieds;sa=catup;cat=' . $row['ID_CAT'] . '">' . $txt['class_text_up'] . '</a>&nbsp;<a href="' . $scripturl . '?action=classifieds;sa=catdown;cat=' . $row['ID_CAT'] . '">' . $txt['class_text_down'] . '</a></td>
<td class="windowbg"><a href="' . $scripturl . '?action=classifieds;sa=editcat;cat=' . $row['ID_CAT'] . '">' . $txt['class_text_edit'] . '</a>&nbsp;<a href="' . $scripturl . '?action=classifieds;sa=deletecat;cat=' . $row['ID_CAT'] . '">' . $txt['class_text_delete'] . '</a>
<br />
<a href="' . $scripturl . '?action=classifieds;sa=catperm;cat=' . $row['ID_CAT'] . '">',$txt['class_text_cat_permisisons'],'</a>

</td>';

}


echo '</tr>';

if ($subcats_linktree != '')
{
echo '
<tr class="windowbg3">
<td colspan="',$num_cols , '">&nbsp;<span class="smalltext">',($subcats_linktree != '' ? '<b>' . $txt['class_sub_cats'] . '</b>' . $subcats_linktree : ''),'</span></td>
</tr>';
}


}

change to
Code: [Select]
$maxrowlevel = 4;

$rowlevel = 0;
while($row = $smcFunc['db_fetch_assoc']($dbresult))
{

$totallistings  = Classifieds_GetListingTotals($row['ID_CAT']);
if ($rowlevel == 0)
echo '<tr>';


echo '<td class="windowbg"><a href="' . $scripturl . '?action=classifieds;cat=' . $row['ID_CAT'] . '">' . parse_bbc($row['title']) . '</a></td>';


if($rowlevel < ($maxrowlevel-1))
$rowlevel++;
else
{
echo '</tr>';
$rowlevel = 0;
}
}

if($rowlevel !=0)
{
echo '</tr>';
}
Title: Re: About Layout Options
Post by: ajac63 on May 22, 2019, 03:05:15 am
Once again many thanks for your help.  Thing is I can find a section of code beginning with:

while($row = $smcFunc['db_fetch_assoc']($dbresult))
      {

         $totallistings  = Classifieds_GetListingTotals($row['ID_CAT']);
but not ending with:
<tr class="windowbg3">
            <td colspan="',$num_cols , '">&nbsp;<span class="smalltext">',($subcats_linktree != '' ? '<b>' . $txt['class_sub_cats'] . '</b>' . $subcats_linktree : ''),'</span></td>
         </tr>';
         }


      }

So, I didn't replace it just inn case.
Title: Re: About Layout Options
Post by: SMFHacks on May 22, 2019, 07:33:47 am
It starts on line 569 in that file.
Title: Re: About Layout Options
Post by: ajac63 on May 22, 2019, 01:27:48 pm
OK, it works. I now have the 12 categories arranged in 4 columns by 3 rows, but without the category images.  I know you told me already, but is there no way of showing the images?
Title: Re: About Layout Options
Post by: SMFHacks on May 22, 2019, 01:32:14 pm
Well you could. Just depends on how you want it to show up.
Title: Re: About Layout Options
Post by: ajac63 on May 22, 2019, 06:02:51 pm
I was thinking of having them to the left of category names.
Title: Re: About Layout Options
Post by: SMFHacks on May 22, 2019, 08:05:22 pm
Try this instead
Code: [Select]
// Max Items per row
$maxrowlevel = 4;

$rowlevel = 0;
while($row = $smcFunc['db_fetch_assoc']($dbresult))
{

$totallistings  = Classifieds_GetListingTotals($row['ID_CAT']);
if ($rowlevel == 0)
echo '<tr>';


if($row['imageurl'] == '' && $row['imagefilename'] == '')
echo '<td colspan="2" class="windowbg"><a href="' . $scripturl . '?action=classifieds;cat=' . $row['ID_CAT'] . '">' . parse_bbc($row['title']) . '</a> ' . (!empty($modSettings['class_showrss_bycat']) ? '<a href="' . $scripturl . '?action=classifieds;sa=rss;cat=' . $row['ID_CAT'] . ';type=recent"><img src="' . $modSettings['class_url'] . 'rss.png" alt="rss" /></a>' : '') . '</td>';
else
{
if($row['imagefilename'] == '')
echo '<td class="windowbg2"><a href="' . $scripturl . '?action=classifieds;cat=' . $row['ID_CAT'] . '"><img src="' . $row['imageurl'] . '" border="0" alt=""  /></a></td>';
else
echo '<td class="windowbg2"><a href="' . $scripturl . '?action=classifieds;cat=' . $row['ID_CAT'] . '"><img src="' . $modSettings['class_url'] . 'catimgs/' . $row['imagefilename'] . '" border="0" alt=""  /></a></td>';


echo '<td class="windowbg"><a href="' . $scripturl . '?action=classifieds;cat=' . $row['ID_CAT'] . '">' . parse_bbc($row['title']) . '</a> ' . (!empty($modSettings['class_showrss_bycat']) ? '<a href="' . $scripturl . '?action=classifieds;sa=rss;cat=' . $row['ID_CAT'] . ';type=recent"><img src="' . $modSettings['class_url'] . 'rss.png" alt="rss" /></a>' : '') . '</td>
';
}


if($rowlevel < ($maxrowlevel-1))
$rowlevel++;
else
{
echo '</tr>';
$rowlevel = 0;
}
}

if($rowlevel !=0)
{
echo '</tr>';
}
Title: Re: About Layout Options
Post by: ajac63 on May 23, 2019, 04:14:49 am
Great, you certainly know your stuff!  Works exactly how I had it in mind and has also given me a good insight into how php works.