TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,915
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online

[block] Approved Articles / Sorted, Paginated, Categorized, & Customized

Started by tim antley, September 21, 2008, 11:13:59 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Renegd98

This will great for use once the problem with displaying articles is fixed in Beta 3....

limteam

how can i:
-add "search an article by letter";
-put the $limit on the results shown on page;
-show results from specific allowed categories $cats_allowed ;

Ianedres

Searching is not implemented in this snippet.

Forthcoming releases of TP will have article searching, and depending on how its code works, may try to work with the snippet code to produce some results.

I assume your other two questions are related to the first?

limteam

A| B| C| D|

when i select letter A underneath there should be listed all articles that start on letter A.and other two questions are related to the first one...

limteam

this is a code:


$mode = (isset($_GET['mode'])) ? intval($_GET['mode']) : '0';
switch ($mode)
{
case '1':

$cats_allowed = array(1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 19, 20, 21, 22, 23, 24, 25, 26); // valid category numbers; '0' = all categories; separate values with commas

$name = mysql_escape_string(trim($_GET['name']));
$name = substr($name,0,1);

foreach($cats_allowed as $v){
$num = mysql_num_rows(mysql_query("SELECT (`id`) FROM `smf_tp_articles` WHERE `subject` LIKE '$name%' AND 'category' = ".$v.""));
}

$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
$all = ceil($num/50);
if ($page>$all || $page<1) {
$page=1; $start=0;
} else {
$start = $page*50-50;

    if($num<1){   
    echo '<b>None!!!!</b><br/>';   
    }else{   
    echo 'Articles: '.$num.'<br/>';
    foreach($cats_allowed as $v){
    $WR=mysql_query("SELECT * FROM `smf_tp_articles` WHERE `subject` LIKE '$name%'  AND 'category' = ".$v." ORDER BY `id` DESC LIMIT ".$start.",50");
    }   
    while($q=mysql_fetch_array($WR)){
    $q['subject'] = htmlspecialchars($q['subject']);
    echo '<a href="./index.php?page='.$q['id'].'">'.$q['subject'].'</a><br/>';
       
}

for($i =1; $i <= $all; $i++)
{
echo $pr=(($i == 1 || $i == $all || abs($i-$page) < 2) ? ($i == $page ? " [$i] " : ' <b><a href="./index.php?action=Leha&mode=1&amp;name='.$name.'&amp;page='.$i.'">'.$i.'</a></b>') : (($pr == ' ... ' || $pr == '')? '' : ' ... '));
}
}
break;



default:
echo '<a href="./index.php?action=Leha&mode=1&amp;name=A">A</a>| ';
echo '<a href="./index.php?action=Leha&mode=1&amp;name=B">B</a>| ';
echo '<a href="./index.php?action=Leha&mode=1&amp;name=C">C</a>| ';
echo '<a href="./index.php?action=Leha&mode=1&amp;name=D">D</a>| ';
echo '<a href="./index.php?action=Leha&mode=1&amp;name=E">E</a>| ';
echo '<a href="./index.php?action=Leha&mode=1&amp;name=F">F</a>| ';
echo '<a href="./index.php?action=Leha&mode=1&amp;name=G">G</a>| ';
echo '<a href="./index.php?action=Leha&mode=1&amp;name=H">H</a>| ';
echo '<a href="./index.php?action=Leha&mode=1&amp;name=I">I</a>| ';
echo '<a href="./index.php?action=Leha&mode=1&amp;name=J">J</a>| ';
echo '<a href="./index.php?action=Leha&mode=1&amp;name=K">K</a>| ';
echo '<a href="./index.php?action=Leha&mode=1&amp;name=L">L</a>| ';
echo '<a href="./index.php?action=Leha&mode=1&amp;name=M">M</a>| ';
echo '<a href="./index.php?action=Leha&mode=1&amp;name=N">N</a>| ';
echo '<a href="./index.php?action=Leha&mode=1&amp;name=O">O</a>| ';
echo '<a href="./index.php?action=Leha&mode=1&amp;name=P">P</a>| ';
echo '<a href="./index.php?action=Leha&mode=1&amp;name=Q">Q</a>| ';
echo '<a href="./index.php?action=Leha&mode=1&amp;name=R">R</a>| ';
echo '<a href="./index.php?action=Leha&mode=1&amp;name=S">S</a>| ';
echo '<a href="./index.php?action=Leha&mode=1&amp;name=T">T</a>| ';
echo '<a href="./index.php?action=Leha&mode=1&amp;name=U">U</a>| ';
echo '<a href="./index.php?action=Leha&mode=1&amp;name=V">V</a>| ';
echo '<a href="./index.php?action=Leha&mode=1&amp;name=W">W</a>| ';
echo '<a href="./index.php?action=Leha&mode=1&amp;name=X">X</a>| ';
echo '<a href="./index.php?action=Leha&mode=1&amp;name=Y">Y</a>| ';
echo '<a href="./index.php?action=Leha&mode=1&amp;name=Z">Z</a>| ';
break;
}


But this code don't work with $cats_allowed.
who can repair that script?

Ianedres

The code you have posted in the last post is not mine, and I don't see a practical approach in combining what you ask as it relates to the original snippet topic here.

I'll also ask that you start your own topic for support requests for such things to keep this topic for the snippet clear of any confusion.

Once the next version of TP is released, I do plan to upgrade this and other snippets for compatibility.

nasir

 Can you tell me does it work for TP v1.0

if it does,,,where to put the code ??

G6Cad

Did you read the first post and the rest of them as they hold all info you need, we do not run around with silverplatter and serv our members, they have to do some work on their own....

Ianedres

Thanks G6...

Any snippet's I have posted will have all the information in the first message, along with the most current version of the code with any changes.

It is intended to be used as a php article, just to be clear.

dimdom

Is there a way to add the first image in every article (with fixed dimensions) in the list?

This website is proudly hosted on Crocweb Cloud Website Hosting.