Problem mit ArticleCollection Klasse

Gesperrt
Flo2
Beiträge: 8
Registriert: Sa 2. Okt 2004, 20:09
Kontaktdaten:

Problem mit ArticleCollection Klasse

Beitrag von Flo2 »

Hallo,

ich habe ein Problem mit der ArticleCollection Klasse (http://www.contenido.de/forum/viewtopic.php?t=2087)... und zwar gibt die Article-Collection zwar die richtige Anzahl an Objekten aus (wenn 2 Artikel in einer Kategorie sind, wird die while-schleife 2x durchlaufen), aber die Funktionen getContent und get scheinen nicht zu funktionieren (geben nichts aus). Hier ist der Quelltext:

Code: Alles auswählen

<?php
$articleListOptions = array("idcat" => 18,          // Idcat (Muss angegeben werden)
                                      "lang"  => $lang,       // Sprach id (optional), standard ist die aktive Sprache
                                      "client"=> $client,     // Mandant id (optional), standard ist der aktive Mandant
                                      "start" => true,        // Startartikel
                                      "order" => "title",   // Feldname nach dem sortier wird, siehe tabelle 'con_art_lang'
                                      "direction" => "asc"); // Ab- oder Aufsteigende sortierung ('asc', oder 'desc')

$articleList = new ArticleCollection($articleListOptions);

$loopcount = 0;

while ($article = $articleList->nextArticle()) {
    $head1 = $article->getContent('head', 1);
    $id = $article->get('idart'); 
   
if($idart == $id) echo ' <strong>' . $head1 . '</strong>';
    else echo ' <a href="front_content.php?idcatart='.$id.'">' . $head1 . '</a>';

$loopcount++;
}
?>
Weder in der Variable $head1 noch in $id befindet sich etwas. Eine Überschrift (CMS_HEAD[1]) ist definitv auf allen Seiten vorhanden, aber selbst falls die nicht da wäre müsst ja wenigstens die artikel-id zurückgegeben werden.

Wahrscheinlich irgendein dummer Fehler von mir, aber ich komm einfach nicht drauf...

Danke schonmal für die Hilfe
Flo
swelpot
Beiträge: 101
Registriert: Mo 26. Jul 2004, 20:42
Wohnort: Rhein-Main
Kontaktdaten:

Beitrag von swelpot »

Hi,

ggf. sind bei der Instanzierung der Collection die Variablen $lang und/oder $client leer und nicht 1 wie sie es wahrsch. sein müssten. Lass sie doch mal weg...

Wenn das dann funktioniert wäre da noch eins:
die normale Headline aus dem Standardmodul hat den Typ "htmlhead" und nicht "head". (getContent-Funktion)

Grüße

Stefan
Flo2
Beiträge: 8
Registriert: Sa 2. Okt 2004, 20:09
Kontaktdaten:

Beitrag von Flo2 »

Geht leider immer noch nicht... das "head" stimmt schon, hab das Standardmodul geändert (mit "htmlhead" geht es auch nicht, das hatte ich vorsorglich schon getestet).

Das Komische ist, dass ich auf der gleichen Contenido-Installation (unter einem anderen Mandanten) genau den gleichen Quelltext in einem Modul habe, und da geht es.

Noch andere Ideen woran es liegen könnte?

Viele Grüße
Flo
SkyBlader
Beiträge: 303
Registriert: Do 18. Mär 2004, 16:23
Wohnort: Ratingen / NRW
Kontaktdaten:

Beitrag von SkyBlader »

um die id zu hohlen

Code: Alles auswählen

$id = $article->getField("idart");
zum anderen .. "head" gibt es nicht ....

wenn du die "htmlhead" meinst, heißt das auch so

Code: Alles auswählen

// erste HMTL Kopfzeile
$htmlhead_1 = $article->getContent("htmlhead",1);

// erster HTML Text
$html_1 = $article->getContent("html",1);

// erste Kopfzeile rein Textbassierend
$texthhead_1 = $article->getContent("headline",1);

// erstes textfeld
$text_1 = $article->getContent("text",1);
Dazu mal ein kleiner auszug aus der class.article.php
/**
* Contenido API - Article Object
*
* This object represents a Contenido article
*
* Create object with
* $obj = new Article(idart, client, lang [, idartlang]);
*
* You can now read the article properties with
* $obj->getField(property);
*
* List of article properties:
*
* idartlang - Language dependant article id
* idart - Language indepenant article id
* idclient - Id of the client
* idtplcfg - Template configuration id
* title - Internal Title
* pagetitle - HTML Title
* summary - Article summary
* created - Date created
* lastmodified - Date lastmodiefied
* author - Article author (username)
* online - On-/offline
* redirect - Redirect
* redirect_url - Redirect URL
* artsort - Article sort key
* timemgmt - Time management
* datestart - Time management start date
* dateend - Time management end date
* status - Article status
* free_use_01 - Free to use
* free_use_02 - Free to use
* free_use_03 - Free to use
* time_move_cat - Move category after time management
* time_target_cat - Move category to this cat after time management
* time_online_move - Set article online after move
* external_redirect - Open article in new window
* locked - Article is locked for editing
*
* You can extract article content with the
* $obj->getContent(contype [, number]) method.
*
* To extract the first headline you can use:
*
* $headline = $obj->getContent("htmlhead", 1);
*
* If the second parameter is ommitted the method
* returns an array with all available content of
* this type. The array has the following schema:
*
* array( number => content );
*
* $headlines = $obj->getContent("htmlhead");
*
* $headlines[1] First headline
* $headlines[2] Second headline
* $headlines[6] Sixth headline
*
* Legal content type string are defined in the Contenido
* system table 'con_type'. Default content types are:
*
* NOTE: This parameter is case insesitive, you can use
* html or cms_HTML or CmS_HtMl. Your don't need start with
* cms, but it won't crash if you do so.
*
* htmlhead - HTML Headline
* html - HTML Text
* headline - Headline (no HTML)
* text - Text (no HTML)
* img - Upload id of the element
* imgdescr - Image description
* link - Link (URL)
* linktarget - Linktarget (_self, _blank, _top ...)
* linkdescr - Linkdescription
* swf - Upload id of the element
*
* @package Contenido_API
* @version 1.0
*
* @author Jan Lengowski <Jan.Lengowski@4fb.de>
* @copyright four for business AG 2003
*/
so long

Stefan
Contenido 4.4.4/4.4.5 - Contenido 4.5.x

Module:sn_multinav für 4.5.x
Flo2
Beiträge: 8
Registriert: Sa 2. Okt 2004, 20:09
Kontaktdaten:

Beitrag von Flo2 »

danke, habe deine tipps getestet,er bekommt die id immer noch nicht... ob jetzt get() oder getField() "richtiger" ist weiß ich nicht, bei einem anderen mandanten funktioniert es auf jeden fall mit get(), und so wird es ja auch hier beschrieben (nochmal der verweis auf http://www.contenido.de/forum/viewtopic.php?t=2087).

zu "head", das gibt es, funktioniert nämlich bei besagtem anderem mandanten auch. "htmlhead" ist es ganz bewusst nicht. habe es jetzt aber trotzdem mal mit "headline" getestet, auch da ist die variable leer.

wie gesagt, das modul funktioniert (ganz genau der gleiche quelltext) bei einem anderen mandanten auf der gleichen contenido installation. hab keinen schimmer, an was es noch liegen könnte...

gruß
flo
SkyBlader
Beiträge: 303
Registriert: Do 18. Mär 2004, 16:23
Wohnort: Ratingen / NRW
Kontaktdaten:

Beitrag von SkyBlader »

mhhh ...

nehm mal zum debuggen folgenden code:

Code: Alles auswählen

<?php 
$articleListOptions = array("idcat" => 18,          // Idcat (Muss angegeben werden) 
                                      "lang"  => $lang,       // Sprach id (optional), standard ist die aktive Sprache 
                                      "client"=> $client,     // Mandant id (optional), standard ist der aktive Mandant 
                                      "start" => true,        // Startartikel 
                                      "order" => "title",   // Feldname nach dem sortier wird, siehe tabelle 'con_art_lang' 
                                      "direction" => "asc"); // Ab- oder Aufsteigende sortierung ('asc', oder 'desc') 

$articleList = new ArticleCollection($articleListOptions); 

$loopcount = 0; 

while ($article = $articleList->nextArticle()) { 
    print_r ( $article );
    echo "<br />";
    print_r ($article->getContent("head");
    echo "<br />";
$loopcount++; 
} 
?>
habs nich getestet, falls nich geht las mal die zweite print_r anweisung weg

stefan
Contenido 4.4.4/4.4.5 - Contenido 4.5.x

Module:sn_multinav für 4.5.x
Flo2
Beiträge: 8
Registriert: Sa 2. Okt 2004, 20:09
Kontaktdaten:

Beitrag von Flo2 »

print_r($article->getContent("head")) gibt garnichts aus.

print_r ($article) gibt folgendes aus:
article Object
(
[table] => con_art_lang
[db] => db_contenido Object
(
[Host] => localhost
[Database] => xxxxxx
[User] => xxxxxx
[Password] => xxxxxx
[Auto_Free] => 0
[Debug] => 0
[Halt_On_Error] => report
[Seq_Table] =>
[Record] =>
[Row] => 1
[Errno] => 0
[Error] =>
[type] => mysql
[revision] => 1.2
[Link_ID] => Resource id #43
[Query_ID] => Resource id #88
)

[primaryKey] => idartlang
[values] =>
[modifiedValues] =>
[lasterror] =>
[virgin] => 1
[cache] =>
[lifetime] => 10
[tab] => Array
(
[art] => con_art
[art_lang] => con_art_lang
[cat] => con_cat
[cat_art] => con_cat_art
[cat_tree] => con_cat_tree
[cat_lang] => con_cat_lang
[clients] => con_clients
[clients_lang] => con_clients_lang

Code: Alles auswählen

 => con_code
            [content] => con_content
            [lang] => con_lang
            [lay] => con_lay
            [mod] => con_mod
            [news] => con_news
            [news_rcp] => con_news_rcp
            [stat] => con_stat
            [stat_archive] => con_stat_archive
            [status] => con_status
            [tpl] => con_template
            [tpl_conf] => con_template_conf
            [type] => con_type
            [upl] => con_upl
            [keywords] => con_keywords
            [area] => con_area
            [actions] => con_actions
            [nav_main] => con_nav_main
            [nav_sub] => con_nav_sub
            [rights] => con_rights
            [container] => con_container
            [container_conf] => con_container_conf
            [files] => con_files
            [framefiles] => con_frame_files
            [plugins] => con_plugins
            [phplib_active_sessions] => con_phplib_active_sessions
            [phplib_auth_user_md5] => con_phplib_auth_user_md5
            [actionlog] => con_actionlog
            [link] => con_link
            [meta_type] => con_meta_type
            [meta_tag] => con_meta_tag
            [groups] => con_groups
            [group_prop] => con_group_prop
            [groupmembers] => con_groupmembers
            [config] => con_config
            [config_client] => con_config_client
            [data] => con_data
            [lang_bereich] => con_lang_bereich
            [lang_key] => con_lang_key
            [lang_value] => con_lang_value
            [sequence] => con_sequence
            [sessions] => con_sessions
            [user_prop] => con_user_prop
            [inuse] => con_inuse
        )

    [content] => 
)[/quote]
SkyBlader
Beiträge: 303
Registriert: Do 18. Mär 2004, 16:23
Wohnort: Ratingen / NRW
Kontaktdaten:

Beitrag von SkyBlader »

mhhh

mach mal anstatt print_r ($article) folgendes:

Code: Alles auswählen


....
$tst = %article->getContent("head");
print_r($tst);
....

Contenido 4.4.4/4.4.5 - Contenido 4.5.x

Module:sn_multinav für 4.5.x
Flo2
Beiträge: 8
Registriert: Sa 2. Okt 2004, 20:09
Kontaktdaten:

Beitrag von Flo2 »

du meinst sicher "$article" - gibt auch nix aus :?

gruß
flo
Flo2
Beiträge: 8
Registriert: Sa 2. Okt 2004, 20:09
Kontaktdaten:

Beitrag von Flo2 »

Ich hab das Ganze jetzt einfach direkt per MySQL-Query gelöst, das funktioniert.

Trotzdem Danke für die Hilfe :)
Gesperrt