categorieen weergeven

Home Forums Games discussies categorieen weergeven

5 berichten aan het bekijken - 1 tot 5 (van in totaal 5)
  • Auteur
    Berichten
  • #119030
    YorickYorick
    Deelnemer
    10

    Ik ben een beetje aan het prutsen aan een nieuwe site en zit met volgend probleem:

    Ik zou graag achter mijn artikelen bij recent nieuws de categorie weergeven waarin ze zitten. Nu heb ik al vanalles aan het proberen geweest maar ik kom er niet uit… Ik kom nu voorlopig tot onderstaand resultaat: (Enkel bovenste artikel zit in categorie ‘neobux’, rest in ‘bux.to’)

    [img]http://img393.imageshack.us/img393/9241/probleemdutchbuxsy1.th.jpg[/img][img]http://img393.imageshack.us/images/thpix.gif[/img]

    hieronder staat de code die achter recent nieuws zit.

    Code:

    get( ‘source’, 2 ); //default to category

    // id value corresponding to selected items/cats/section

    $id = trim( $params->get( ‘id’ ) );

    $id = rtrim($id,”,”); //strip trailing comma, if any

    // number of items to display

    $number = trim( $params->get( ‘items’, 5 ) ); //default to five items

    //type of link list: 1=plain; 2= bulleted; 3= numbered

    $type = $params->get( ‘list_type’, 2 ); //default to bulleted

    //order of link list: created, title, id

    $order = $params->get( ‘list_order’, ‘created’ ); //default to created

    //sort order of link list: asc; desc

    $sort = $params->get( ‘list_sort’, ‘desc’ ); //default to descending

    //Show date below title link?

    $show_date = $params->get( ‘show_date’, ‘no’ ); //default to no date

    //Format of list date?

    $date_format = $params->get( ‘date_format’, ‘%Y/%m/%d’ ); //default to year/month/day

    //enable mouseover overlib tooltip?

    $enable_tooltip = $params->get( ‘enable_tooltip’, ‘no’ ); //default to no tooltip

    /*Content Link Mouseover Fields */

    //fields to show in overlib tooltip

    $tooltip_intro = $params->get( ‘tooltip_intro’, ‘no’ ); //default to no

    $tooltip_intro_word_count = $params->get( ‘tooltip_intro_word_count’ );

    if(!$tooltip_intro_word_count && $tooltip_intro_word_count != 0){

    $tooltip_intro_word_count = ’25’; //default to 25 words

    }

    $tooltip_created = $params->get( ‘tooltip_created’, ‘no’ ); //default to no

    $tooltip_created_date_format = $params->get( ‘tooltip_created_date_format’, ‘%Y/%m/%d’ ); //default to year/month/day

    $tooltip_author = $params->get( ‘tooltip_author’, ‘no’ ); //default to no

    //tooltip styles

    $tooltip_bgcolor = $params->get( ‘tooltip_bgcolor’, ‘#24537d’ ); //default to dark blue

    $tooltip_fgcolor = $params->get( ‘tooltip_fgcolor’, ‘#E1F0FF’ ); //default to light blue

    $tooltip_border = $params->get( ‘tooltip_border’, ‘1’ ); //default to 1px border

    $tooltip_capcolor = $params->get( ‘tooltip_capcolor’, ‘#ffffff’ ); //default to white

    $tooltip_textcolor = $params->get( ‘tooltip_textcolor’, ‘#000000’ ); //default to black

    $tooltip_images = $params->get( ‘tooltip_images’, ‘1’ ); //default to true

    //extra tooltip parameters

    $tooltip_extra_invocation_string = $params->get( ‘tooltip_extra_invocation_string’ );

    if(!$tooltip_extra_invocation_string){

    $tooltip_extra_invocation_string = “”; //default

    }

    else{

    $tooltip_extra_invocation_string = “,”.$tooltip_extra_invocation_string;

    }

    //checking if function exists first allows multiple copies of module on page and avoids redeclaration error

    if(!function_exists(”getContentItems”)){

    //Get Content Function

    function getContentItems($source, $id, $number, $order, $sort, $date_format, $tooltip_intro){

    //returns selected content items as associative array

    global $mainframe, $database, $my;

    switch($source){

    //check type of content item to return, set where clause. Allows for multiple categories, sections, items

    case ‘1’: //content item

    $where = “id IN ($id)”;

    break;

    case ‘2’: //category

    $where = “catid IN ($id)”;

    break;

    case ‘3’: //section

    $where = “sectionid IN ($id)”;

    break;

    }

    $nullDate = $database->getNullDate(); //used for published check

    $now = _CURRENT_SERVER_TIME; //ditto

    $content = array(); //stores content items

    if($tooltip_intro==’yes’){ $introtext = ‘, introtext ‘;}else{$introtext=””;} //get introtext only if requested

    //Select query checks whether item is published, is not checked out and whether user has permission to access item

    $query=”SELECT id, title, created, created_by”.$introtext.” FROM #__content WHERE ($where)” //has specified id(s)

    . ” AND ( ‘$now’ <= publish_down OR publish_down = '$nullDate' AND state = 1 )" //still up and published . " AND ( '$now' >= publish_up OR publish_up = ‘$nullDate’)” //publishing period is active

    . ” AND ( checked_out = 0 OR checked_out = $my->id )” //not checked out or checked out by me

    . ” AND (access <= $my->gid)” //permission to access

    . ” ORDER BY $order $sort”

    . ” LIMIT $number”; //limit number of items to return

    //query the DB

    $database->setQuery($query);

    $database->query();

    //load items into object array

    $content_list=$database->loadObjectList();

    $total=count($content_list);

    //loop through and generate the array of content item links

    for($i=0;$i<$total;$i++){ //print $mainframe->getItemid($content_list[$i]->id);

    $link=”index.php?option=com_content&task=view&id=”.$content_list[$i]->id.”&Itemid=”.$mainframe->getItemid($content_list[$i]->id);

    $content[$i][’id’]=$content_list[$i]->id;

    $content[$i][’title’]=$content_list[$i]->title;

    $content[$i][’author’]=$content_list[$i]->created_by;

    if($introtext){$content[$i][’introtext’]=$content_list[$i]->introtext;}

    $content[$i][’date’]=mosFormatDate($content_list[$i]->created, $date_format);

    $content[$i][’link’]=sefRelToAbs($link); //search engine friendly URL, if SEF is off normal URL is displayed

    }

    return $content;

    }

    }

    if(!function_exists(”getIntroText”)){

    //returns introtext chunk

    function getIntroText($text, $length, $tooltip_images){

    $text = str_replace(”{mosimage}”,””,$text); //strip out mosimage tags

    $text = preg_replace(”/(rn|n|r)/”, “”, $text); //replace new line characters, important!

    if($length==0){

    return $text.”…”;

    }

    $words = explode(” “,$text); //convert text to array of words for count

    for($i=0;$i<$length;$i++){ $introtext .= $words[$i]." "; //make HTML safe string for overlib popup } rtrim($introtext," "); //trim trailing space. if(!$tooltip_images){ $introtext = preg_replace("/]+>/i”, “”, $introtext);

    }

    $introtext = $introtext . “…”; //add …

    return $introtext;

    }

    }

    if(!function_exists(”getAuthorName”)){

    //return authors name

    function getAuthorName($id){

    global $database;

    $query = “SELECT name”

    . “n FROM #__users”

    . “n WHERE id = $id”

    ;

    $database->setQuery( $query );

    if ($name=$database->loadResult()){

    return $name;

    }

    else{

    return false;

    }

    }

    }

    if(!function_exists(”buildTooltip”)){

    //make the tooltip content, wrap content in styleable css spans

    function buildTooltip($item, $tooltip_created, $tooltip_created_date_format, $tooltip_author, $tooltip_intro, $tooltip_intro_word_count, $tooltip_images){

    $text=””;

    if($tooltip_created == ‘yes’){

    $text.= “” . strftime($tooltip_created_date_format, strtotime($item[’date’])). “
    “;

    }

    if($tooltip_author == ‘yes’){

    $author=getAuthorName($item[’author’]);

    if($author){

    $text .= “” . $author . “
    “;

    }

    }

    if($tooltip_intro == ‘yes’){ $text.= “” . getIntroText($item[’introtext’],$tooltip_intro_word_count, $tooltip_images) . ““;}

    return htmlspecialchars(addslashes(str_replace(’,’,’,’,$text)));

    }

    }

    //end function declarations

    //get, process data and output content

    $items=getContentItems($source, $id, $number, $order, $sort, $date_format, $tooltip_intro); //get content items array using module parameters

    $output=array(); //buffer to hold content items

    switch($type){

    //determine type of link list to generate

    case ‘1’: //plain list

    $start_list = “”; //list starting tag

    $end_list = “”; //list ending tag

    $start_link = “”; //list item starting tag

    $end_link = “
    “; //list item ending tag

    break;

    case ‘2’: //bulleted

    $start_list = “

    “;

    $start_link = “

  • “;

    break;

    case ‘3’: //numbered list

    $start_list = “

    “;

    $start_link = “

    “;

    break;

    default: //default to bulleted

    $start_list = “

    “;

    $start_link = “

    “;

    break;

    }

    //custom stylesheet. edit ‘modules/mod_content_links.css’ to add custom style to the link list

    echo ““;

    if($enable_tooltip == ‘yes’){

    //load support js library

    mosCommonHTML::loadOverlib();

    }

    $output[’header’] = “

    “; //end the block

    //print out the nicely formatted link list

    print $output[’header’]

    . $output[’content’]

    . $output[’footer’];

    //done!

    ?>

#537053
imported_Z@3 RedrumZ@3 Redrum.
Deelnemer
15

Dit is natuurlijk een naald zoeken in ‘n hooiberg, flats, dit is de code, kijk maar wat… Iets specifieke aub.

Je moet in ieder geval hier zijn denk ik. Ik ken je veldstructuur echter niet, maar zoiets kan het zijn:

Code:

$output[’content’] .= “n
“.$item[’date’].”“.$end_link.”n”;}


Maak ‘n variabel aan die de categorie eruit haalt (meestal te maken dmv $var, en zet die erachter. Dan krijg je zoiets bv:

Code:

$output[’content’] .= “n
“.$item[’date’].”
Categorie: “. $item[’categorie’].”
“.$end_link.”n”;}

#537054
YorickYorick
Deelnemer
10

sorry, dacht dat ik erbij had gezet welk deel ik specifiek bedoelde niet dus.. en die variabel die de categorie ophaalt, moet die tussen de

Code:

foreach($items as $item){

staan?

#537055
imported_Z@3 RedrumZ@3 Redrum.
Deelnemer
15

die zul je idd wel even erbij moeten zetten als die niet wordt gefetcht, maa je kunt het uiteraard altijd proberen.

#537056
YorickYorick
Deelnemer
10

ik heb nu dit:

Code:

if(count($items)>0){
$q = “SELECT catid FROM dutchbux_content WHERE sectionid=’$id’ AND state = 1 ORDER BY publish_up DESC LIMIT 0,10”;
$query = mysql_query($q);
{
foreach($items as $item)
{

if($enable_tooltip ==’yes’){

//generate tooltip content

$tooltip = “onmouseover=”overlib('”.buildTooltip($item, $tooltip_created, $tooltip_created_date_format, $tooltip_author, $tooltip_intro, $tooltip_intro_word_count, $tooltip_images).”‘, CAPTION, ‘”.addslashes(htmlspecialchars(preg_replace(”/(rn|n|r)/”, “”, $item[’title’]))).”‘, FGCOLOR, ‘”.$tooltip_fgcolor.”‘, BGCOLOR, ‘”.$tooltip_bgcolor.”‘, BORDER, “.$tooltip_border.”, CAPCOLOR, ‘”.$tooltip_capcolor.”‘, TEXTCOLOR, ‘”.$tooltip_textcolor.”‘”.$tooltip_extra_invocation_string.”);” onmouseout=”return nd();” “;}

else{

$tooltip = “”;

}
while ($row = mysql_fetch_assoc($query))
{
$catid = $row[’catid’];
$q2 = “SELECT title FROM dutchbux_categories WHERE id = ‘$catid'”;
$query2 = mysql_query($q2);
while ($rij = mysql_fetch_assoc($query2))
{
$cattitel = $rij[’title’];
// $output[’content’] .= $cattitel;

}
//$output[’content’] .= $cattitel;
}

$output[’content’] .= $start_link; //start link html
$output[’content’] .= ““.$item[’title’].”$cattitel”;
$output[’content’] .= “
“; //generate SEF URL
}

}


het enige probleem dat ik nu heb is dat achter mijn titels altijd dezefde categorie wordt weergegeven, terwijl als ze apart print met $output .= $cattitel; dat ze wel correct achter elkaar worden weergegeven. Maar van zodra ik ze achter een titel wil zetten veranderd het overal naar dezefde categorie.

5 berichten aan het bekijken - 1 tot 5 (van in totaal 5)
  • Je moet ingelogd zijn om een antwoord op dit onderwerp te kunnen geven.

Naar boven