|
|

|


|

|

|

|
|
|
|
|
Manuel.
Member
Joined: 01/19/2004
posts: 8
Location: Germany
|
|
Posted: 01/20/2004 2:33:00 PM
|
|
Meine Suchmaschine umfasst 330 Kategorien. Nun möchte ich ein weiteres Theme erstellen, in dem nur rund 10 dieser Kategorien angeboten werden (also nur ein Teil des Datenbestandes). Wie mache ich das?
|
|
|
|
Manuel.
Member
Joined: 01/19/2004
posts: 8
Location: Germany
|
|
Posted: 01/21/2004 9:04:00 AM
|
|
I try it with my doubtful English abilities: :wink:
(%cat_num_links%)
Wie kann ich die Anzahl der Links in einer ausgewählten Kategorie ausgeben?
--> How do I get the number of links in a selected category?
for example : (%cat_num_links_cat=17%)
(%insert_new_links%)
Wie erhalte ich alle neuen Links aus ausgewählten Kategorien?
--> How do I get all new links (only) from selected categories?
for example: (%insert_new_links_cat=5,17,19,32,46%)
(%stats_links%)
Wie erhalte ich die Gesamtsumme aller Links aus ausgewählten Kategorien?
--> How do I get the number of all entries (only) from all selected categories?
for example: (%stats_links_cat=5,17,19,32,46%)
I use In-link Version 2.2.10.
<font size=-1>[ This Message was edited by: Manuel. on 2004-01-21 09:26 ]</font>
|
|
|
|
Dmitry
admin
Joined: 01/05/2002
posts: 1495
Location: United States
|
|
Posted: 01/21/2004 1:00:00 PM
|
|
Hello Manuel,
Thanks for helping me with translation :wink:. I'll look into this in a few days and will post it here.
Thank you once again.
|
|
|
|
Manuel.
Member
Joined: 01/19/2004
posts: 8
Location: Germany
|
|
Posted: 02/06/2004 3:23:00 AM
|
|
I need this information for a new project. When may I expect an answer?
|
|
|
|
Dmitry
admin
Joined: 01/05/2002
posts: 1495
Location: United States
|
|
Posted: 02/06/2004 5:07:00 PM
|
|
Hello,
Sorry for delay, I was sure that already completed this.
First you'll need to patch your current "includes/templ_lib.php" file. Find "parse" funcation and replace it with this one.
//main parsing func
function parse($t_name,$visited=""
{
global $t_cache, $filedir, $parse_email, $email_body;
//check for recursion in templates
if(!$parse_email)
{
if(ereg("%$t_name%",$visited))
{
echo "***Error: recursion in branch $visited, node $t_name. Aborting template.";
return;
}
else
$visited.="%$t_name%";
if($t_cache[$t_name] == "" //check if cashed
$t_cache[$t_name]=template($t_name); //load if not cashed
$t=$t_cache[$t_name]; //get local copy of the cash - speed
}
else
{
$t=$email_body;
$parse_email=false;
}
#main parsing loop
$t_len=strlen($t);
$o=""; //output HTML & PHP
//tags parse
for($i=0;$i<$t_len;$i++)
{ #search for next special tag
$tagOpen=strpos($t,"<%",$i);
if  $tagOpen===false)
{ #only HTML left
$o.=substr($t,$i);
break;
}
else
{ //get end of tag
$tagClose=strpos($t,"%>",$tagOpen);
$tag=substr($t,$tagOpen+2,$tagClose-$tagOpen-2);
//add all HTML before
$o.=substr($t,$i,$tagOpen-$i);
//process tag
if($col_pos=strpos($tag,":" )
{ $vtag_name=substr($tag,0,$col_pos);
$vtag_value=substr($tag,$col_pos+1);
switch($vtag_name)
{
case "language":
global $$vtag_value;
$o.=$$vtag_value;
break;
case "include":
$o.=parse(substr($tag,8),$visited);
break;
case "nav":
$o.=nav($vtag_value);
break;
case "inl_language":
$o.=inl_language($vtag_value);
break;
case "drop_lang":
$o.=drop_lang($vtag_value);
break;
case "drop_theme":
$o.=drop_theme($vtag_value);
break;
case "drop_results":
$o.=drop_results($vtag_value);
break;
default:
if  function_exists($vtag_name))
$o.= $vtag_name($vtag_value);
elseif  file_exists($filedir."mods/$vtag_name.mod" )
{
include_once($filedir."mods/$vtag_name.mod" ;
$func_name = "runmod_$vtag_name";
if  function_exists($func_name))
$o.= $func_name($vtag_value);
}
elseif  file_exists($filedir."mods/$vtag_name.mod.php" )
{
include_once($filedir."mods/$vtag_name.mod.php" ;
$func_name = "runmod_$vtag_name";
if  function_exists($func_name))
$o.= $func_name($vtag_value);
}
break;
}
}
elseif(function_exists($tag))
$o.=$tag();
elseif(file_exists($filedir."mods/$tag.mod" )
{
include_once($filedir . "mods/$tag.mod" ;
$func_name="runmod_$tag";
if(function_exists($func_name))
$o.=$func_name();
}
elseif(file_exists($filedir."mods/$tag.mod.php" )
{
include_once($filedir . "mods/$tag.mod.php" ;
$func_name="runmod_$tag";
if(function_exists($func_name))
$o.=$func_name();
}
else
$o.=$tag;
//move ptr
$i=$tagClose+1;
}
}
return $o;
}
Then append function to the end of the same file.
function cat_num_links_cat($vtag = null)
{
global $conn, $cat, $cat_query, $link_new;
$_new = $link_new;
//Number of days links considered as a NEW; comment this out to use default Admin setting
$_new = 5;
$_tags = explode("|", $vtag);
if  ($_tags[0] == "new" ||  $_tags[1] == "new" )
{
$cutoffdate = mktime(0,0,0,date("m" ,date("d" -$_new,date("Y" );
$_add_new = " AND inl_links.link_date>='".$cutoffdate."'";
}
if  $_catIDs =  $_tags[0] &&  $_tags[0] != "new" )? $_tags[0] : $cat)
{
$sql = "SELECT COUNT(inl_links.link_id) FROM inl_lc LEFT JOIN inl_links ON inl_lc.link_id=inl_links.link_id WHERE inl_links.link_vis='1' AND inl_lc.link_pend='0' AND inl_lc.cat_id IN (".$_catIDs." ".$_add_new;
echo $sql;
$rs = $conn->Execute($sql);
$ret =  $rs && !$rs->EOF)? $rs->fields[0] : 0;
}
return $ret;
}
It would one tag for all three cases:
1. Counter of NEW links from 1, 3, 4 categories <%cat_num_links_cat:1,3,4|new%>
2. Counter of NEW links from 1 (one category) categories <%cat_num_links_cat:1|new%>
3. Counter of links from 1 (one category) categories <%cat_num_links_cat:1%> (same for multiple cats)
In case if you don't specify category/s then it will the current one you are in. This way you can simply put <%cat_num_links_cat:new%> to get number of NEW links in current category.
Please don't forget to backup your files prior to make any changes.
Thank you.
|
|
|
|
Manuel.
Member
Joined: 01/19/2004
posts: 8
Location: Germany
|
|
Posted: 02/08/2004 8:27:00 AM
|
|
Thank you, it works :smile:
The third question was
"How do I get all new links (only) from selected categories?
for example: (%insert_new_links_cat=5,17,19,32,46%)"
Unfortunately I make much work for you, sorry... :wink:
|
|
|
|
Dmitry
admin
Joined: 01/05/2002
posts: 1495
Location: United States
|
|
Posted: 02/08/2004 2:47:00 PM
|
|
Hello Manual,
Here is example for third scenario:
<%cat_num_links_cat:5,17,19,32,46|new%>
It will return new links from the listed categories
Thank you.
|
|
|
|
Manuel.
Member
Joined: 01/19/2004
posts: 8
Location: Germany
|
|
Posted: 02/08/2004 5:31:00 PM
|
|
Sorry, this is for the number of new links from selected categories. --> cat_num_link. Thanks again for the answer for 2 of 3 questions. :smile:
But the third question was "insert_new_link", i want to display all new links from selected categories: "display all new links from category 1,3,10". The Content, not the number.
<font size=-1>[ This Message was edited by: Manuel. on 2004-02-08 17:33 ]</font>
|
|
|
|
Dmitry
admin
Joined: 01/05/2002
posts: 1495
Location: United States
|
|
Posted: 02/09/2004 10:18:00 AM
|
|
Hello here it is,
Add this function end end of templ_lib.php file.
function cat_list_links_cat($vtag = null)
{
global $conn, $cat, $link_query, $link_new, $link_data;
$_new = $link_new;
// Number of days links considered as a NEW; comment this out to use default Admin setting
$_new = 5;
$tpl = "list_links"; // Specify template which will be parsed.
$limit = 10; // Limit links (comment out the line to print all)
$_add_limit = $limit? " LIMIT 0, ".$limit : "";
$_tags = explode("|", $vtag);
if  ($_tags[0] == "new" ||  $_tags[1] == "new" )
{
$cutoffdate = mktime(0,0,0,date("m" ,date("d" -$_new,date("Y" );
$_add_new = " AND inl_links.link_date>='".$cutoffdate."'";
}
if  $_catIDs =  $_tags[0] &&  $_tags[0] != "new" )? $_tags[0] : $cat)
{
$sql = $link_query." WHERE inl_links.link_vis='1' AND inl_lc.link_pend='0' AND inl_lc.cat_id IN (".$_catIDs." ".$_add_new." ORDER BY inl_links.link_date DESC".$_add_limit;
if  $rs = $conn->Execute($sql))
{
while  $rs && !$rs->EOF)
{
$link_data = $rs->fields;
$ret.= parse($tpl);
$rs->MoveNext();
}
}
}
return $ret;
}
And call for this in your templates:
<%cat_list_links_cat:1,3,10|new%>
Thank you.
|
|
|
|
Manuel.
Member
Joined: 01/19/2004
posts: 8
Location: Germany
|
|
Posted: 02/09/2004 10:37:00 AM
|
|
Thank you very much for your help, now all is perfect! :smile:
|

|

|
|