To use this website completely, it is necessary to store cookies on your computer.
 

* Navigator

Expand - Collapse

* Statistic


  • *Total Posts: 16430
  • *Total Topics: 2522
  • *Online Today: 5
  • *Most Online: 292
(12. Nov 2016, 09:37:31)
  • *Users: 0
  • *Guests: 0
  • *Spiders: 1
  • *Total: 1

  • *Google

* Calendar

Mo
Tu
We
Th
Fr
Sa
Su
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

Article Block Request?

Started by trench, 11. Aug 2011, 03:12:21

previous topic - next topic

0 Members and 0 Guests are viewing this topic.

trench

11. Aug 2011, 03:12:21
Can we have a php article block something similar to this one? Maybe max 5 article links show on block then click to see all option?



[attachment deleted by admin]

feline

#1
11. Aug 2011, 10:47:46
It's possible If you write one ..  ;)
Many are stubborn in relation to the path, a few in relation to the target.

trench

#2
16. Aug 2011, 15:18:05
Thats why I post in the feature request!   :D O0

feline

#3
16. Aug 2011, 19:08:52
That you can handle with a simple php block, also see the Articlelist sample code
Many are stubborn in relation to the path, a few in relation to the target.

trench

#4
18. Aug 2011, 11:41:29
okay, great! Thanks!

trench

#5
18. Aug 2011, 12:10:17
Code Select
global $txt;
$result = PortaMx_getArticles('pmxfunctions');
list($cat, $data) = each($result);
echo '
<div style="text-align:right;">
  <em>'. $txt['pmx_more_articles'] .'<br />'. $data['link'] .'</em><hr />';

foreach($data['articles'] as $art)
  echo $art['link'] .'<br />';

echo '
</div>';


Found the code Fel and it works great in a BiB block which I recently figured out how to use. Now how does this part work?

QuoteYou can call the function PortaMx_getArticles with a single category name or a list of category names like: PortaMx_getArticles('cat1, cat2, cat3'); and you can also use the category ID's. In this case you have to call the function like: PortaMx_getArticles('1, 2, 3', true);


I try this and nothing appears.

Code Select
global $txt;
$result = PortaMx_getArticles('1, 2, 3', true);
list($cat, $data) = each($result);
echo '
<div style="text-align:right;">
  <em>'. $txt['pmx_more_articles'] .'<br />'. $data['link'] .'</em><hr />';

foreach($data['articles'] as $art)
  echo $art['link'] .'<br />';

echo '
</div>';

feline

#6
18. Aug 2011, 13:41:59
You have categories with the ID 1, 2, 3 and these have articles?
Many are stubborn in relation to the path, a few in relation to the target.

trench

#7
18. Aug 2011, 13:52:36
yes.  I think I got it to work, but only one article category per block.. with this PortaMx_getArticles('CATEGORYNAME');

Code Select
global $txt;
$result = PortaMx_getArticles('CATEGORYNAME');
list($cat, $data) = each($result);
echo '
<div style="text-align:right;">
  <em>'. $txt['pmx_more_articles'] .'<br />'. $data['link'] .'</em><hr />';

foreach($data['articles'] as $art)
  echo $art['link'] .'<br />';

echo '
</div>';


I couldnt figure out how to get it to work the other way with the Category Number.  How do I get this to limit of only last five articles in each category instead of all of them?  When I keep adding, I only want last 5 article to appear in each category? this possible?

[attachment deleted by admin]

feline

#8
18. Aug 2011, 16:51:14
The function PortaMx_getArticles() accept category ID's or Category names.
if you use ID's the parameter must ('1,2,3', true)
if you use names the parameter must ('name,name, name')
You can't set a Limit for the articles, but in the foreach loop you can limit the articles ...
Many are stubborn in relation to the path, a few in relation to the target.

trench

#9
19. Aug 2011, 15:05:56
Quote from: feline on 18. Aug 2011, 16:51:14
The function PortaMx_getArticles() accept category ID's or Category names.
if you use ID's the parameter must ('1,2,3', true)
if you use names the parameter must ('name,name, name')
You can't set a Limit for the articles, but in the foreach loop you can limit the articles ...


Can you explain more how to limit the loop?

feline

#10
19. Aug 2011, 19:29:31
Replace:
Code Select
foreach($data['articles'] as $art)
  echo $art['link'] .'<br />';


with:
Code Select
$cnt = 3;
foreach($data['articles'] as $art)
{
  if($cnt > 0)
    echo $art['link'] .'<br />';
  $cnt--;
}

That show the first 3 articles ...

[/code]
Many are stubborn in relation to the path, a few in relation to the target.

trench

#11
20. Aug 2011, 16:18:21
excellent! Will test later this week and let you know! Thanks FEL! O0