désolé, j’ai (encore) été trop rapide...
Je dois avouer que je n’ai pas compris ton problème.

PHP error debug Error: array_merge() [function.array-merge]: Argument #1 is not an array Error type/ Nr.: Warning - 2 File: /Users/blahblah/Sites/manager/includes/document.parser.class.inc.php(730) : eval()'d code Line: 220
Here you go. Thanks. When I try with &LR_selectDocsWithChildren=`1` then I get an error as if it can't search children within folders. [!ListRelated? &LR_selectDocs=`126` &LR_contentParagraph=`introtext` &LR_sortBy=`date` &LR_sortDir=`DESC` &LR_skipUnpublished=`1` &LR_skipDeleted=`1` &LR_title=`Some title for testing`!]
$relatives = $modx->dbQuery($relatedSql);
die($relatedSql );

The above is when I don't use &LR_selectDocsWithChildren=`1` When I do use &LR_selectDocsWithChildren=`1` then I get this error instead « MODx Parse Error » MODx encountered the following error while attempting to parse the requested resource: « PHP Parse Error » PHP error debug Error: array_merge() [function.array-merge]: Argument #1 is not an array Error type/ Nr.: Warning - 2 File: /Users/blahblah/Sites/manager/includes/document.parser.class.inc.php(730) : eval()'d code Line: 220
Any significance to the format difference in the SELECTs
of yours = content.id IN(4557) and mine = (content.id IN(126))
La différence de format dans ton select et le mien a-t-il une signification ?Réponse:
- Quel est le numéro de document qui appelle le snippet ? (Je suppose que c'est le 90) Yes, 90 - Ton document 126 est il un répertoire ? Yes 126 is a répertoire (if that means "folder") - Si c'est le cas, celui-ci a t-il des documents children qui sont publiés et non supprimés ? Yes, there are published children inside - Y a t il des documents qui ont pour mot clé 'finder' dans ce répertoire ? Yes, "Finder" - Quelle version de modX utilises-tu ? 0.9.5 beta 5
, essaye de mettre à jour le snippet avec le code suivant :<?php // -------------------- // Snippet: ListRelated // -------------------- // Version: 0.9.2 ModXfied by mr_go // Date: 2006.04.07 // Originaly made by // [email protected] // Modxifed by [email protected] // Then by mr_go // added the option to set the in menu option // This snippet was designed to show a list of pages that are // related based on specified keywords, or those used in the // current page // // Configuration Settings // LR_keywords [ string ] // This is a comma separated list of keywords that can be set // from the snippet parameter ONLY. Ex: // [[ListRelated?LR_keywords=fun,functional,good stuff]] // If no snippet variable is set, related pages will be found // based on the host page's keywords. // $maxRelated [ int ] // The maximum number of related pages you want to have. Can also // be set/overridden as the snippet variable "LR_max" as in: // [[ListRelated?LR_max=5]] $maxRelated = 10; // $relatedListTitle [ string ] // Give your related list of links a title if you desire- otherwise // set as an empty string ''. Can also be declared in snippet call // with "LR_title" like: // [[ListRelated?LR_title=Other links you might like]] $relatedListTitle = 'Et aussi...'; // $removeNewlines [ true | false ] // As always, with lists, it's best NOT to have new lines and whitespace // with IE. For debugging and reading source code, set to false, for live // implementation and styling, try setting to true. $removeNewlines = true; // $sortBy [ 'date' | 'pagetitle' ] // Field you would like to sort by. Options include: // date dates will be sorted by pub_date if it exists, else createdon // pagetitle page title // Can also be set in snippet call with $LR_sortBy (see example under $sortDir) $sortBy = 'date'; // $sortDir [ 'ASC' | 'DESC' ] // Choose to sort in ascending (ASC) or descending (DESC) order. Can be set // in snippet call with $LR_sortDir: // [[ListRelated??LR_sortBy=date&LR_sortDir=DESC]] $sortDir = 'DESC'; // $showhidemenu [ 0 | 1 ] // Must we hide the documents that are set to hide in menu // when set to 0 it wil NOT show the documents that are marked as hide in menu $showhidemenu = 0; // LR_skipPages [ string ] // Must we skip some pages (given by page#1,page#2,page#3..) e.g: [[ListRelated? &LR_skipPages='21,45,51']] // Default value : '' // $skipPages = ""; // LR_skipDeleted [0 | 1] // Default value : 0 // Must we skip deleted pages // LR_skipUncacheable [0 | 1] // Default value : 0 // Must we skip pages that are not cacheable // LR_skipUnsearchable [0 | 1] // Default value : 0 // Must we skip pages that are not searchable // LR_skipFolder [0 | 1] // Default value : 0 // Must we skip pages that are marked as folder // LR_skipUnpublished [0 | 1] // Default value : 0 // Must we skip pages that are not published // LR_label [string] // Default value : 'pagetitle' // Content of the title attribute for <a> anchor must be a field label of the prefix_site_content table // e.g = [[ListRelated? &LR_label='title']] // LR_titleAttribute [string] // Default value : 'longtitle' // Content of the title attribute for <a> anchor must be a field label of the prefix_site_content table // e.g = [[ListRelated? &LR_titleAttribute='description']] /*LR_contentParagraph [ string ] // Content of the <p> tag if mentioned. // Default value : '' // Content of contentParagraph must be a field label of the prefix_site_content table // e.g = [[ListRelated? &LR_contentOption='description']] */ /*LR_selectDocs [ string ] // Default value : '' // Must we intergrate only pages found in the list e.g = [[ListRelated? &LR_onlyDocs='5,51']] */ /*LR_selectDocsWithChildren [ 0 | 1 ] // Default value : 1; // If we are in LR_selectDocs mod search, must we include children (recursive). */ // Styles // .LR_listTitle class for list title // .LR_linksList class for ul element // .LR_description class for p element // *********************************** // END CONFIG SETTINGS // THE REST SHOULD TAKE CARE OF ITSELF // *********************************** // assign IE variable $newline = ($removeNewlines)? '':"\n"; // assign appropriate default or passed variables $maxRelated = (isset($LR_max))? $LR_max : $maxRelated; $relatedListTitle = (isset($LR_title))? $LR_title : $relatedListTitle ; $sortBy = (isset($LR_sortBy))? $LR_sortBy: $sortBy ; $sortDir = (isset($LR_sortDir))? $LR_sortDir :$sortDir ; $querySkipPages = (isset($LR_skipPages) && ($LR_skipPages!='') )? " AND (NOT(content.id IN(".$LR_skipPages."))) " : "" ; $queryOnlyPages = (isset($LR_selectDocs) && ($LR_selectDocs!=''))? " AND (content.id IN(".$LR_selectDocs.")) " : "" ; $querySkipDeleted = (isset($LR_skipDeleted) && ($LR_skipDeleted))? " AND (content.deleted=0) " : "" ; $querySkipUnCacheable = (isset($LR_skipUncacheable) && ($LR_skipUncacheable))? " AND (content.cacheable) " : "" ; $querySkipUnSearchable = (isset($LR_skipUnsearchable) && ($LR_skipUnsearchable))? " AND (content.searchable) " : "" ; $querySkipUnPublished = (isset($LR_skipUnpublished) && ($LR_skipUnpublished))? " AND (content.published) " : "" ; $querySkipFolder = (isset($LR_skipFolder) && ($LR_skipFolder))? " AND (NOT content.isfolder) " : "" ; $complete_select_query = array("content.id", "content.pagetitle", "content.description", "content.longtitle"); $choosenLabel = 'pagetitle'; $choosenTitleAttribute = 'longtitle'; $choosenContentParagraph = ''; // assign appropriate displayed values AND query select options if(isset($LR_label)) { $choosenLabel = $LR_label; if(!in_array("content.".$LR_label,$complete_select_query)) array_push($complete_select_query,"content.".$LR_label); } if(isset($LR_titleAttribute)) { $choosenTitleAttribute = $LR_titleAttribute; if(!in_array("content.".$LR_titleAttribute,$complete_select_query)) array_push($complete_select_query,"content.".$LR_titleAttribute); } if(isset($LR_contentParagraph)) { $choosenContentParagraph = $LR_contentParagraph; if(!in_array("content.".$LR_contentParagraph,$complete_select_query)) array_push($complete_select_query,"content.".$LR_contentParagraph); } $choosenContentParagraph = (isset($LR_contentParagraph))? $LR_contentParagraph :''; // Make array of keywords from snippet or from current page. Snippet // variables have priority. if (isset($LR_keywords)){ $kArray= explode(",",$LR_keywords); } else { $kArray = $modx->getKeywords(); } if(!function_exists('getRecursiveAllChildren')) { function getRecursiveAllChildren($modXObject,$idDoc,$arrayChildren = array()) { array_push($arrayChildren,$idDoc); $arrayDocChild = $modXObject->getAllChildren($idDoc); foreach($arrayDocChild as $id=>$val) $arrayChildren = getRecursiveAllChildren($modXObject,$val['id'],$arrayChildren); return($arrayChildren); } } // if there are keywords, make the list $relatedOutput = ''; if ($kArray){ $keyString = ''; foreach ($kArray as $key){ $keyString .= "'".$key."',"; } $keyString = substr($keyString,0,strlen($keyString)-1); // make sql statement for retreiving similar pages $pre= $modx->dbConfig['dbase'].".".$modx->dbConfig['table_prefix'];
$all_custom_queries = "";
if (($LR_selectDocs!='') && isset($LR_selectDocsWithChildren) && ($LR_selectDocsWithChildren))
{
$arraySelectedDocs = explode(',',trim($LR_selectDocs));
$arrayAllChildren = array();
foreach($arraySelectedDocs as $arrayVal)
{
$arrayAllChildren = array_unique(array_merge($arrayAllChildren,getRecursiveAllChildren($modx,$arrayVal),array($arrayVal)));
}
$queryIn = "AND content.id IN(".implode(",",$arrayAllChildren).") ";
$all_custom_queries = $queryIn." ".$querySkipFolder." ".$querySkipDeleted." ".$querySkipUnCacheable." ".$querySkipUnSearchable." ".$querySkipUnPublished." ".$querySkipPages;
}
else
$all_custom_queries = $queryOnlyPages." ".$querySkipFolder." ".$querySkipDeleted." ".$querySkipUnCacheable." ".$querySkipUnSearchable." ".$querySkipUnPublished." ".$querySkipPages;
$complete_select_query = implode(',',$complete_select_query);
$relatedSql = "SELECT ".$complete_select_query.",
IF(content.pub_date > 0, content.pub_date, content.createdon) AS date,
COUNT(keywords.id) as total_kw
FROM
".$pre."site_content AS content,
".$pre."keyword_xref AS xref,
".$pre."site_keywords AS keywords
WHERE keywords.keyword IN (".$keyString.")
$all_custom_queries
AND xref.keyword_id = keywords.id
AND content.hidemenu = ".$showhidemenu."
AND content.id = xref.content_id
AND content.id != ".$modx->documentObject['id']."
GROUP BY content.id
ORDER BY total_kw DESC, ". $sortBy . ' ' . $sortDir ."
LIMIT ".$maxRelated.";";
$relatives = $modx->dbQuery($relatedSql);
$relativeCount = $modx->recordCount($relatives);
$relArray = array();
for($i=0;$i<$relativeCount;$i++) {
array_push($relArray,$modx->fetchRow($relatives));
}
$getAttribute = "id,$choosenLabel,$goodTitleAttribute";
$getAttribute .=($choosenContentParagraph!='')? $choosenContentParagraph:"";
// start output if we have results
if ($relativeCount){
$relatedOutput .= ($relatedListTitle )?'<span class="LR_listTitle">' . $relatedListTitle . '</span>' : '' ;
$relatedOutput .= '<ul class="LR_linksList">'.$newline;
for ($li=0;$li<$relativeCount;$li++){
$goodLabel = $relArray[$li][$choosenLabel];
$goodTitleAttribute = $relArray[$li][$choosenTitleAttribute];
$goodContentParagraph = (($choosenContentParagraph!='')&& isset($relArray[$li][$choosenContentParagraph])) ? '<p class="LR_description">'.$relArray[$li][$choosenContentParagraph].'</p>':'';
$relatedOutput .= '<li><a href=[~' . $relArray[$li]['id'] . '~] title="' .$goodTitleAttribute. '">' .$goodLabel. '</a>'.$goodContentParagraph.'</li>'.$newline;
}
$relatedOutput .='</ul>'.$newline;
}
}
return $relatedOutput;
?>