We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 23506
    • 156 Posts
    Нужно сделать что-то ввиде телефонного справочника, нужно сделать так чтобы документы распределялись по первой букве заголовка и потом выводились ввиде алфавита на странице.
    Как так сделать?
      • 897
      • 1,620 Posts
      чем вы водите документы?
        "Und wenn du lange in einen Abgrund blickst, blickt der Abgrund auch in dich hinein."

        Не используйте Revo для "просто сайтов". Используйте Evo

        Who can defeat the Russian bear?
        • 23506
        • 156 Posts
        [[Ditto? &startID=`54` &summarize=`5` &removeChunk=`Comments` &trunc=`0` &tpl=`ditto_blog2` &paginate=`1` &extenders=`summary,dateFilter` &paginateAlwaysShowLinks=`1` &tagData=`documentTags` &truncText=`Читать далее...`]
          • 897
          • 1,620 Posts
          ну добавьте &sortBy и &sortDir
            "Und wenn du lange in einen Abgrund blickst, blickt der Abgrund auch in dich hinein."

            Не используйте Revo для "просто сайтов". Используйте Evo

            Who can defeat the Russian bear?
            • 23506
            • 156 Posts
            Да, но как сделать список букв вверху страницы?
              • 897
              • 1,620 Posts
              простой способ: создать дерево из папок от А до Я и помещать документы в соответствующие папки. список букв делается Wayfinedr’ом

              сложный способ: создать TV типа DropDownList с вариантами возможных значений из алфавита, в документах в ручную выставлять значение TV. список буковок сделать вручную, благо алфавит у нас меняется не часто.

              способ еще сложнее: написать плагин, который будет генерировать список буковок из заданной папки с документами по первым буквам имени документа.
                "Und wenn du lange in einen Abgrund blickst, blickt der Abgrund auch in dich hinein."

                Не используйте Revo для "просто сайтов". Используйте Evo

                Who can defeat the Russian bear?
                • 23506
                • 156 Posts
                Нашел сниппет, модифицирую его.
                http://modxcms.com/A-to-Z-Listing-523.html
                  • 23506
                  • 156 Posts
                  <?php
                  /** 
                  *
                  * Snippet: Site A to Z 
                  * Author: Garry Nutting ([email protected])
                  * Version: 0.6
                  * Date: 14/06/06
                  * License: LGPL applies
                  *
                  * Updates: 	0.4 - fixed issue when startid only contains 1 child, fixed problem with conditional statements for startid
                  *          	0.5 - tweaked the code in lots of places to handle startIDs better.
                  *		0.6 - 	* add ability to display items that have a non-alpha starting 'letter'
                  *			* ability to add multiple start ids (comma separated value)
                  *		
                  */
                  
                  /********************* Setup  ***************************/
                  
                  //-- Alphabet Letters
                  $alphabet = array (
                  	"А",
                  	"Б",
                  	"В",
                  	"Г",
                  	"Д",
                  	"Е",
                  	"Ж",
                  	"З",
                  	"И",
                  	"К",
                  	"Л",
                  	"М",
                  	"Н",
                  	"О",
                  	"П",
                  	"Р",
                  	"С",
                  "Т",	
                  	"У",
                  	"Ф",
                  	"Х",
                  	"Ц",
                  	"Ч",
                  	"Ш",
                  "Щ",
                  	"Э",
                  	"Ю",
                  "Я",	
                  "Все"
                  );
                  
                  //-- This is the entry in the $alphabet that returns the full listing
                  $all = "Все";
                  
                  //-- This is the entry in the $alphabet that returns non-alpha entries
                  $nonAlpha = '0-9';
                  
                  //-- Gets the selected letter if a letter has been chosen
                  $letter = (isset ($_GET['letter'])) ? stripslashes($_GET['letter']) : 'Все';
                  
                  
                  //-- Gets the selected letter if a letter has been chosen
                  //-- Main column of the site_content table to return, suggested selections are: pagetitle, longtitle, 
                  $title = (isset ($title)) ? stripslashes($title) : 'pagetitle';
                  
                  //-- Message that gets displayed if no pages match the letter selected
                  $norecords = (isset ($norecords)) ? stripslashes($norecords) : 'Нет ничего на эту букву';
                  
                  //-- Introduction message, used when the page is first opened and no letter has been selected
                  $intro = (isset ($intro)) ? stripslashes($intro) : 'Выберите букву';
                  
                  //-- Optional second column from the site_content table, for example, could be used to display the introtext
                  $summary = (isset ($summary)) ? stripslashes($summary) : '';
                  
                  //-- Optional start id, can be used to specify a sub-folder for the A to Z
                  $startid = (isset ($startid)) ? stripslashes($startid) : 0;
                  
                  //-- Used to determine if the 'hidemenu' option should be used, boolean value (DO NOT change line below)
                  $hidemenu = (isset ($hidemenu) && $hidemenu == 'false') ? '' : ' AND hidemenu=0';
                  
                  $lcount = count($alphabet); // number of letters in the alphabet
                  
                  $empty = false; // for determining when no children exist for a start ID
                  
                  $nonAlphaFilter = (in_array($nonAlpha, $alphabet)) ? '^[a-z]' : false; //sets the NOT RLIKE filter for non-alpha entries
                  
                  //-- placeholder variables
                  $atozresults = '';
                  $atozletters = '';
                  
                  //-- used for makeURL for current page
                  $docid = $modx->documentObject['id'];
                  
                  //-- Output Alphabet Headings
                  for ($i = 0; $i < $lcount; $i++) {
                  	if ($i < $lcount -1) {
                  		$atozletters .= '<span class="azalpha"><a href="' . $modx->makeURL($docid, '', 'letter=' . $alphabet[$i] . '') . '">' . $alphabet[$i] . '</a></span><span class="azsep"> | </span>';
                  	} else {
                  		$atozletters .= '<span class="azalpha"><a href="' . $modx->makeURL($docid, '', 'letter=' . $alphabet[$i] . '') . '">' . $alphabet[$i] . '</a></span>';
                  	}
                  }
                  
                  if ($letter <> '') {
                  
                  	# Processes subfolders if a $startid has been passed
                  	if (trim($startid) <> '') {
                  
                  		//-- split out the start id values
                  		$startArray = explode(',', $startid);
                  
                  		//-- loop through each start id
                  		foreach ($startArray as $startid) {
                  			//-- if not numeric, then loop now
                  			if (!is_numeric($startid)) continue;
                  			//--get top level id's
                  			$table = $modx->getFullTableName("site_content");
                  			$where = 'parent="' . $startid . '" AND published=1 AND deleted=0' . $hidemenu . ' AND privateweb=1';
                  			$orderby = $title . ' ASC';
                  			$rs = $modx->db->select("*", $table, $where, $orderby, '');
                  
                  			//-- add top level id's to array
                  			while ($row = $modx->db->getRow($rs)) {
                  				$atozarray[] = $row['id'];
                  			}
                  
                  			//--recurse through top level id's and grab sub id's
                  			for ($i = 0; $i < count($atozarray); $i++) {
                  				$where = 'parent="' . $atozarray[$i] . '" AND published=1 AND deleted=0' . $hidemenu . ' AND privateweb=1';
                  				$rs = $modx->db->select("*", $table, $where, $orderby, '');
                  				if ($modx->db->getRecordCount($rs) > 0) {
                  					while ($row = $modx->db->getRow($rs)) {
                  						$atozarray[] = $row['id'];
                  					}
                  				}
                  			}
                  		}
                  		
                  		//-- setup vars for array parsing       
                  		$startwhere = '';
                  		$startcount = count($atozarray);
                  		$startloop = 0;
                  
                  		//-- parse array into sql WHERE statement
                  
                  		if (count($atozarray) == 1) {
                  			$startwhere = ' id="' . $atozarray[0] . '"';
                  		}
                  		elseif (count($atozarray) == 0) {
                  			$empty = true; //no values to return
                  		} else {
                  			foreach ($atozarray as $item) {
                  				if ($startloop == 0) {
                  					$startwhere .= ' (id="' . $item . '"';
                  					$startloop = $startloop +1;
                  				}
                  				elseif ($startloop == $startcount -1) {
                  					$startwhere .= ' OR id="' . $item . '")';
                  					$startloop = $startloop +1;
                  				} else {
                  					$startwhere .= ' OR id="' . $item . '"';
                  					$startloop = $startloop +1;
                  				}
                  			}
                  		}
                  	}
                  
                  	# Main Processing
                  	//-- run SELECT query
                  	$table = $modx->getFullTableName("site_content");
                  
                  	if (trim($startwhere) <> '') {
                  		//-- check for non-alpha request
                  
                  		if ($letter == $nonAlpha) {
                  			$where = $title . ' NOT RLIKE \'' . $nonAlphaFilter . '\' AND published=1 AND deleted=0' . $hidemenu . ' AND privateweb=1 AND ' . $startwhere;
                  		} else {
                  
                  			$where = $title . ' LIKE \'' . $letter . '%\' AND published=1 AND deleted=0' . $hidemenu . ' AND privateweb=1 AND ' . $startwhere;
                  
                  		}
                  	} else {
                  		$where = $title . ' LIKE \'' . $letter . '%\' AND published=1 AND deleted=0' . $hidemenu . ' AND privateweb=1';
                  	}
                  
                  	$orderby = $title . ' ASC';
                  
                  	if ($letter <> $all) {
                  		$rs = $modx->db->select("*", $table, $where, $orderby, '');
                  	}
                  	elseif (trim($startwhere) <> '' && $letter == $all) {
                  		$rs = $modx->db->select("*", $table, "published=1 AND deleted=0" . $hidemenu . " AND privateweb=1 AND " . $startwhere, $orderby, '');
                  
                  	} else {
                  		$rs = $modx->db->select("*", $table, "published=1 AND deleted=0" . $hidemenu . " AND privateweb=1", $orderby, '');
                  	}
                  
                  	//-- get results
                  	$rscount = $modx->db->getRecordCount($rs);
                  
                  	if (!$empty && $rscount > 0) {
                  		while ($row = $modx->db->getRow($rs)) {
                  		
                  			if (trim($row[$title]) <> '') {
                  $tvoutput=$modx->getTemplateVarOutput('image',$row['id'], 1);
                  $img = $tvoutput['image'];
                  
                  $atozresults .= '<table  cellspacing="0" cellpadding="0" style="background-color:#FFFFFF">';
                  $atozresults .= '                                                      <tr>';
                  $atozresults .= '                                                        <td width="164"><img src="'.$img.'" alt="" align="left" style="margin-right:14px"></td>';
                  $atozresults .= '                                                      	<td width="460">';
                  $atozresults .= '													  <p align="left"><br style="line-height:21px">';
                  $atozresults .= '													    <strong>' . $row[$title] . '</strong><br>';
                  $atozresults .= '                                                        <br style="line-height:5px">' . $row[content] . '';
                  $atozresults .=  '<br style="line-height:19px">';
                  $atozresults .= '	</p></td>';
                  $atozresults .= '</tr>';
                  $atozresults .= '</table><br>';
                  
                  			} else {
                  $tvoutput=$modx->getTemplateVarOutput('image',$row['id'], 1);
                  $img = $tvoutput['image'];
                  $atozresults .= '<table  cellspacing="0" cellpadding="0" style="background-color:#FFFFFF">';
                  $atozresults .= '                                                      <tr>';
                  $atozresults .= '                                                        <td width="164"><img src="'.$img.'" alt="" align="left" style="margin-right:14px"></td>';
                  $atozresults .= '                                                      	<td width="460">';
                  $atozresults .= '													  <p align="left"><br style="line-height:21px">';
                  $atozresults .= '													    <strong>' . $row[$title] . '</strong><br>';
                  $atozresults .= '                                                        <br style="line-height:5px">' . $row[content] . '';
                  $atozresults .=  '<br style="line-height:19px">';
                  $atozresults .= '	</p></td>';
                  $atozresults .= '</tr>';
                  $atozresults .= '</table><br>';
                  			}
                  		
                  		}
                  	} else {
                  		//-- No Records returned from query
                  		$atozresults .= '<ul class="azlist"><li class="azitem">Нет записей</li></ul>';
                  	}
                  } else {
                  	//-- No letter selected yet, display the intro text
                  	$atozresults .= '<ul class="azlist"><li>Выберите одну из букв</li></ul>';
                  }
                  echo "<center>";
                  echo $atozletters;
                  echo "</center><br><br>";
                  echo $atozresults;
                  
                  return '';
                  ?>

                  Модифицировал выше код для русского алфавита. Кодировка UTF-8
                  Все хорошо но есть пару но....
                  Буква "К" русская когда мы на нее нажимаем, контент выводится в кодировке UTF8 (если посмотреть код)
                  Причем если это опера все ок - ссылки так выглядят http://site.ru/index.php?id=69&letter=%D0%9A
                  Если в ИЕ смотреть то http://gktrios.ru/index.php?id=69&letter=К
                  Если в ие подставим %D0%9A все ок, в противном случае скрипт видит что ткой буквы нет и выводит весь список документов.
                  Также баг с буквами "С" и "Т" они выводятся но в разделе на букву "С" например выводится документы на букву "Т" и наоборот.
                  В чем может быть проблемма?
                    • 23506
                    • 156 Posts
                    Упс, буквы вкоде выше потеряли свой вид) Там вместо знаков у меня в сниппетах все в норммальной кодировке видно