Website index | Forum index | FAQ | Zoeken | Gebruikerslijst | Profiel | Bekijk profiel | Log in om je privé berichten te bekijken | Inloggen/Registreer
categorieen weergeven
Bekijk je berichten - Berichten sinds laatste bezoek

 
Plaats nieuw bericht   Plaats Reactie    Evilgamerz.com - Forum Forum Index // Internet & Netwerken
Vorige onderwerp :: Volgende onderwerp  
Auteur Bericht
Yorick
Elite
Elite

Berichten: 1901
Rating: 11
BerichtGeplaatst: Do Nov 06, 2008 6:59 pm    Onderwerp: categorieen weergeven Reageer met quote
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')

hieronder staat de code die achter recent nieuws zit.
Code:
<?php

/**

* @version $Id: mod_content_links.php  2006-11-22 15:12:03Z davidwhthomas $

* @package mod_content_links

* @author David Thomas davidwhthomas@gmail.com

* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php

* @version 1.5

*/



// following line is to prevent direct access to this script via the url

defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );



//Get the Parameters from Module settings page and assign to local variables



// what kind of content to select: 1=item; 2=category; 3=section

$source = $params->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("/(\r\n|\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("/<img[^>]+\>/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.= "<span class='mod_content_links_tooltip_date'>" . strftime($tooltip_created_date_format, strtotime($item['date'])). "</span><br />";

      }

   if($tooltip_author == 'yes'){

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

      if($author){

         $text .= "<span class='mod_content_links_tooltip_author'>" . $author . "</span><br />";

      }

   } 

   if($tooltip_intro == 'yes'){ $text.= "<span class='mod_content_links_tooltip_introtext'>" . getIntroText($item['introtext'],$tooltip_intro_word_count, $tooltip_images) . "</span>";}

   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 = "<br />"; //list item ending tag

   break;   

   case '2': //bulleted

      $start_list = "<ul class='mod_content_links_ul'>";

      $end_list = "</ul>";

      $start_link = "<li class='mod_content_links_title'>";

      $end_link = "</li>";   

   break;

   case '3': //numbered list

      $start_list = "<ol class='mod_content_links_ol'>";

      $end_list = "</ol>";

      $start_link = "<li class='mod_content_links_title'>";

      $end_link = "</li>";   

   break;

   default: //default to bulleted

      $start_list = "<ul class='mod_content_links_ul'>";

      $end_list = "</ul>";

      $start_link = "<li class='mod_content_links_title'>";

      $end_link = "</li>";

   break;

}



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

echo "<link rel='stylesheet' href='$GLOBALS[mosConfig_live_site]/modules/mod_content_links.css' type='text/css'/>";



if($enable_tooltip == 'yes'){

//load support js library

mosCommonHTML::loadOverlib();

}



$output['header'] = "<div class='mod_content_links_block'>"; //start the block

$output['content'] = $start_list."\n"; //start the list



/* Key Content Generation Section  */

//loop through and generate the html for selected content items

if(count($items)>0){
   {
   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("/(\r\n|\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 = "";

      }
      $output['content'] .=  $start_link; //start link html
      $output['content'] .= "<a $tooltip href='".$item['link']."'>".$item['title']."";
            $q4 = "SELECT catid FROM dutchbux_content WHERE sectionid='$id' AND state = 1 ORDER BY publish_up DESC LIMIT 0,10";
      $result = mysql_query($q4);
      while ($line = mysql_fetch_assoc($result)) {
      foreach ($line as $col_value) {
        $q5 = "SELECT title FROM dutchbux_categories WHERE id = '$col_value'";
      $resultaat = mysql_query($q5);
      $fetch = mysql_fetch_assoc($resultaat);
      }
      $resul = $fetch['title'];
      $output['content'] .= $fetch['title'];
      $output['content'] .= "</a>"; //generate SEF URL
      }
   
      
      //show the date in the list too?

      if($show_date=='yes'){

         $output['content'] .= "\n<br /><span class='mod_content_links_date'>".$item['date']."</span>".$end_link."\n";}

      else{

         $output['content'] .= $end_link."\n";

      } //end link html depends on list_type

   }

}
}
else{

   //if no id provided, give an error message

   if(!$id){

      $output['content'] = "<font color='red'>Please enter list source Content ID(s) in module settings</font>";

   }

}



$output['content'] .= "\n".$end_list."\n"; //end the list

$output['footer'] =  "</div>"; //end the block



//print out the nicely formatted link list

print $output['header']

   . $output['content']

   . $output['footer'];

//done!

?>
Terug naar boven
Z@3 Redrum
Evil Gamer
Evil Gamer

Berichten: 22630
Rating: 0
BerichtGeplaatst: Vr Nov 07, 2008 12:26 am    Onderwerp: Reageer met quote
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<br /><span class='mod_content_links_date'>".$item['date']."</span>".$end_link."\n";}

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

Code:
$output['content'] .= "\n<br /><span class='mod_content_links_date'>".$item['date']." <br />Categorie: ". $item['categorie']." </span>".$end_link."\n";}
Terug naar boven
Yorick
Elite
Elite

Berichten: 1901
Rating: 11
BerichtGeplaatst: Vr Nov 07, 2008 4:57 pm    Onderwerp: Reageer met quote
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?
Terug naar boven
Z@3 Redrum
Evil Gamer
Evil Gamer

Berichten: 22630
Rating: 0
BerichtGeplaatst: Za Nov 08, 2008 8:28 am    Onderwerp: Reageer met quote
die zul je idd wel even erbij moeten zetten als die niet wordt gefetcht, maa je kunt het uiteraard altijd proberen.

Geplaatst Za Nov 08, 2008 10:27 am:

Maar misschien is het al genoeg als je bijvoorbeeld $output['content'] .= $fetch['datumveld']; toevoegt.

Geplaatst Za Nov 08, 2008 10:28 am:

Maar misschien is het al genoeg als je bijvoorbeeld $fetch['datumveld'] gebruikt.
Terug naar boven
Yorick
Elite
Elite

Berichten: 1901
Rating: 11
BerichtGeplaatst: Zo Nov 09, 2008 3:47 pm    Onderwerp: Reageer met quote
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("/(\r\n|\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'] .= "<a $tooltip href='".$item['link']."'>".$item['title']."$cattitel";
      $output['content'] .= "</a>"; //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['content'] .= $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.
Terug naar boven

Plaats nieuw bericht   Plaats Reactie    Evilgamerz.com - Forum Forum Index // Internet & Netwerken Tijden zijn in GMT + 1 uur

Pagina 1 van 1