News: September 21st, 2019, The Tinyportal team is pleased to announce the release of ~~ TinyPortal 1.6.4! GET IT NOW!!!

Login  |  Register
HTML5 Icon HTML5 Icon
TP on Social Media
Welcome, Guest. Please login or register.
Did you miss your activation email?

November 12, 2019, 09:29:34 AM

Login with username, password and session length

Recent

Members
Stats
  • Total Posts: 189259
  • Total Topics: 20772
  • Online Today: 68
  • Online Ever: 629
  • (November 08, 2018, 01:36:54 PM)
Users Online
Users: 0
Guests: 49
Total: 49

Author Topic: Article list  (Read 5819 times)

0 Members and 1 Guest are viewing this topic.

Offline Nory

  • Jr. Member
  • **
  • Posts: 10
Article list
« on: May 01, 2017, 04:29:36 PM »
Hello,

Is it possible to display only the list of articles of the same category when clicking on a link that was created in "menu" for example?

Offline Nory

  • Jr. Member
  • **
  • Posts: 10
Re: Article list
« Reply #1 on: May 03, 2017, 10:31:53 AM »
Hello,

The goal is to create a page that lists all items in each category ...

Somebody can help me, please?

Offline lurkalot

  • Administrator
  • *
  • Posts: 6349
    • Camera Craniums
Re: Article list
« Reply #2 on: May 03, 2017, 12:15:08 PM »
Sorry, I meant to come back to this one the other day but forgot to mark it unread.

Now what about using one of these block codes,

Not sure if this one still works as I haven't tried it. Articles - Sorted, Paginated, Categorized, & Customized

Or this one. Articles, simple index

Offline Nory

  • Jr. Member
  • **
  • Posts: 10
Re: Article list
« Reply #3 on: May 04, 2017, 02:22:18 PM »
Hello,

Thank you for your reply, but these doesn't work.

Is it possible to say me where is the code to creat this block "article in a Category"

I search the same in fact...

Offline lurkalot

  • Administrator
  • *
  • Posts: 6349
    • Camera Craniums
Re: Article list
« Reply #4 on: May 04, 2017, 03:30:33 PM »
Hello,

Thank you for your reply, but these doesn't work.

Is it possible to say me where is the code to creat this block "article in a Category"

I search the same in fact...

You mean they don't do what you need, or they actually don't work?  I know the second one I linked you to does work, I use it on two of my sites.  You need (the third one) from this post in that thread, http://www.tinyportal.net/index.php?topic=33208.msg275391#msg275391 The first two codes won't work. ;)

Offline Nory

  • Jr. Member
  • **
  • Posts: 10
Re: Article list
« Reply #5 on: May 05, 2017, 03:40:10 AM »
Hello,

That you for your support.  O0

I am a beginner in PHP.

I forgot to say you, I use Tinyportal Responsive Beta!

I tested the second code again, and it crashed the portal.

The third code work (surrounded in green), but it don't do that I want...
In red, this is the list that I would want on a page.

My request:

Category 1:
Artilce 1
Article 2
Article 3
etc

Category 2:
Artilce 4
Article 6
Article 9
etc

Category 3:
Artilce 5
Article 8
etc

I hope it's more clear...

Offline lurkalot

  • Administrator
  • *
  • Posts: 6349
    • Camera Craniums
Re: Article list
« Reply #6 on: May 05, 2017, 11:12:35 AM »
Yep, did say use the third one. ;)

Ok so using that code with some of it stripped out, and spaces added, what about something like I just added to the left hand side of my test site? http://cctestsite.info/forums/index.php

I have only added two categories atm, just to test, but you can add as many as you like. You can remove or add elements from that code as you wish.

Offline Nory

  • Jr. Member
  • **
  • Posts: 10
Re: Article list
« Reply #7 on: May 05, 2017, 03:43:06 PM »
Hello,

Yessssssss, it's that!!!


Quote
// Specify your categories, comma separated if more than one category.
$categories = array(1,3,10);

These the lines of code, this is the category to display, is that?

But for me, the category are text, not number!

Offline lurkalot

  • Administrator
  • *
  • Posts: 6349
    • Camera Craniums
Re: Article list
« Reply #8 on: May 05, 2017, 04:14:59 PM »
Hello,

Yessssssss, it's that!!!


Quote
// Specify your categories, comma separated if more than one category.
$categories = array(1,3,10);

These the lines of code, this is the category to display, is that?

But for me, the category are text, not number!

OK, to find the category number you need to go to TP Admin > Categories  If you click on the name of one of your categories it should give you the number in the address bar of your browser.

The code I used was from the link I gave you, but I removed some of it. as below.

Code: [Select]
// Configuration

// Specify your categories, comma separated if more than one category.
$categories = array(1);

// The heading area.

echo '
<div style="text-align: center; border: 1px solid #242526; ">   
   <h3>Category 1</h3>
</div>
<br />';

// Now for the code...
global $scripturl, $db_prefix, $smcFunc;

$request = $smcFunc['db_query']('', '
SELECT id, date, subject, views, shortname
FROM {db_prefix}tp_articles
WHERE category IN ({array_int:cats})
AND off = 0
ORDER BY date DESC',
array('cats' => $categories)
);

while ($row = $smcFunc['db_fetch_assoc']($request))
{
   if ($row['shortname'])
   {
      $pageid = $row['shortname'];
   }
   else
   {
      $pageid = $row['id'];
   }

   echo '
   <tr class="windowbg">
      <td style="padding: 3px 0px 3px 10px"><strong><a href="' , $scripturl, '?page=' , $pageid , '">' , $row['subject'] , '</a></strong></td>
      <td style="padding: 3px 0px 3px 10px">' , date('jS, F Y', $row['date']) , '</td>
      <td align="center" style="padding: 3px 0px 3px 15px">' , $row['views'] , '</td>
   </tr><br><br>
';
}

echo '
</table>';

$smcFunc['db_free_result']($request);


I will just say, I'm not a coder, and pretty clueless when it comes to this stuff. So if you have lots of articles in a category you might need to work out a way to limit how many display in that list.  I haven't worked that out yet. ;)


Offline Nory

  • Jr. Member
  • **
  • Posts: 10
Re: Article list
« Reply #9 on: May 08, 2017, 02:49:50 PM »
Hello,

Thank you for your help, that work.

I understand little by little.
I try to modify the code to create the list with the separte categories automaticaly.

Offline lurkalot

  • Administrator
  • *
  • Posts: 6349
    • Camera Craniums
Re: Article list
« Reply #10 on: May 08, 2017, 04:53:45 PM »
Hello,

Thank you for your help, that work.

I understand little by little.
I try to modify the code to create the list with the separte categories automaticaly.

OK, you can repeat the code in the block for each category you want to display. Just add one category number to each code.  That will show the categories separately.  ;)

Offline Nory

  • Jr. Member
  • **
  • Posts: 10
Re: Article list
« Reply #11 on: May 09, 2017, 07:51:17 AM »
Yes, this is what I would do while waiting to find the right code...
because I have lot of categories!!!   :'(