Du bist nicht angemeldet. Der Zugriff auf einige Boards wurde daher deaktiviert.

#1 03. März 2014 22:22

COR9
Server-Pate
Ort: Dresden
Registriert: 09. November 2010
Beiträge: 281

Dropdown Extrafeld in CGBlog

Im Newsmodul gibt es die Möglichkeit, ein Extrafeld als Dropdown-Auswahl fester Begriffe anzulegen. In CGBlog finde ich die Möglichkeit nicht. Wo muss ich schrauben, um die Funktion auch in CGBlog zu bekommen?
Müsste doch irgendwie gehen, da das eine Modul aus dem anderen hervorgegangen ist.
Eine statische Auswahl sollte vollkommen genügen, Mehrfachauswahl brauche ich auch nicht.

Ich habe jeweils die aktuellen Versionen von Core und Modulen installiert.

Offline

#2 04. März 2014 08:52

NaN
Moderator
Ort: Halle (Saale)
Registriert: 09. November 2010
Beiträge: 4.437

Re: Dropdown Extrafeld in CGBlog

CGBlog hat aktuell leider tatsächlich noch kein Dropdown-Feld.
Das kam beim News-Modul auch erst später hinzu.
CGBlog ist da ungefähr auf dem Stand von News 2.6.


Module: GBFilePicker, AdvancedContent
Sicherheit: Beispiel .htaccess-Datei
CMSms 1.12 unter PHP 7:
cmsms-1.12.3.zip (inoffiziell - komplett inkl. Installer)
CMSms 1.12 unter PHP 8:
cmsms-1.12.4.zip (inoffiziell - komplett inkl. Installer)

Offline

#3 05. März 2014 15:52

COR9
Server-Pate
Ort: Dresden
Registriert: 09. November 2010
Beiträge: 281

Re: Dropdown Extrafeld in CGBlog

An welcher/en Datei/en müsste man schrauben?
Ich könnte ziemlich statisch bleiben, da ich nur ein einziges Dropdown-Auswahlfeld brauche und die Werte alle feststehen. Es muss auch niemand welche hinzufügen. Ganz naiv gedacht könnte doch in die editarticle.tpl ein halbwegs statisches Dropdownfeld rein. Allerdings muss ja der je ausgewählte Wert auch verarbeitet werden. Da steh ich dann mal wieder auf dem Schlauch...

Offline

#4 05. März 2014 15:59

nockenfell
Moderator
Ort: Gontenschwil, Schweiz
Registriert: 09. November 2010
Beiträge: 2.934
Webseite

Re: Dropdown Extrafeld in CGBlog

Wenn das Dropdown fix ist, kannst du das wie folgt machen:

Erstelle im Ordner "module_custom/News/templates" die Datei editarticle.tpl (kopiere das Original)

Am Ort deines Dropdown fügst du folgendes ein:

{btReplaceAsDropdown field=$field->field dropdown="wert:Auswahltext,wert2:Auswahltext2"}

Erstelle ein Plugin mit dem Namen "function.btReplaceAsDropdown.php" und folgendem Inhalt und lade dies in den ./plugins Ordner

<?php
#CMS - CMS Made Simple
#(c)2004 by Ted Kulp (wishy@users.sf.net)
#This project's homepage is: http://www.cmsmadesimple.org
#
#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

function smarty_function_btReplaceAsDropdown($params, &$template)
{
  $smarty = $template->smarty;
	$gCms = cmsms();
	global $id;
	
	$data = array();
	foreach (explode(",", $params["dropdown"]) as $cLine) {
	    list ($cKey, $cValue) = explode(':', $cLine, 2);
	    $data[$cKey] = $cValue;
	}
	
  preg_match_all('/\s+([^=]+)="([^"]*)"/', $params['field'], $matches);
  if ($matches) {
    foreach ($matches[1] as $key => $value) {
      $field_params[$value] = $matches[2][$key];
    }
    if ($field_params) {
			$text = '<select class="cms_dropdown" name="'.$field_params['name'].'"';
			$text .= '>';
			$count = 0;
			if (is_array($data) && count($data) > 0)
			{
				foreach ($data as $key=>$value)
				{
				  //		  $value = cms_htmlentities($value);
				$text .= '<option value="'.$key.'"';
					if ($field_params['value'] == $key)
					{
						$text .= ' ' . 'selected="selected"';
					}
					$text .= '>';
					$text .= $value;
					$text .= '</option>';
					$count++;
				}
			}
			$text .= '</select>'."\n";
    }
	}
	
	echo $text;	
	
}

?>

[dieser Beitrag wurde mit 100% recycled bits geschrieben]
Mein Blog  /   Diverse Links rund um CMS Made Simple
Module: btAdminer, ToolBox

Offline