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

#1 04. November 2013 14:44

dlen
probiert CMS/ms aus
Registriert: 05. Februar 2011
Beiträge: 59

Liste aller für Templates verfügbaren Variablen eines Moduls?

Hi,

wenn man Templates kreiert, braucht man die Variablen, die ein Modul zur Verfügung stellt. Leider stehen diese AFAIK nur selten oder gar nicht in der Dokumentation. Kann man sie auf (relativ) einfache Weise herausbekommen?

Danke im Voraus

Dominik

Offline

#2 04. November 2013 15:38

Klenkes
Server-Pate
Ort: 89428 Syrgenstein
Registriert: 17. Dezember 2010
Beiträge: 1.437

Re: Liste aller für Templates verfügbaren Variablen eines Moduls?

Zum Beispiel:

Wobei du anstatt $item deine Variable einfügen musst.
Damit bekommst du meistens alle nötigen Inhalte gut ausgegeben.

Ein allgemeines {get_template_vars} zeigt dir auch noch die Variablen der jeweiligen Seite an.

Offline

#3 05. November 2013 12:49

dlen
probiert CMS/ms aus
Registriert: 05. Februar 2011
Beiträge: 59

Re: Liste aller für Templates verfügbaren Variablen eines Moduls?

Danke für die Antwort, aber ich wollte eigentlich eine Liste der Variablennamen des Moduls, die im Template verwendet werden können. Der Tipp, wie ich deren Inhalt kriege, ist trotzdem nützlich. {get_template_vars} liefert mir, soweit ich das sehen kann, nur die globalen Variablen - oder muss ich das mit speziellen Optionen aufrufen, um auch die Modulvariablen zu kriegen?

Ach, ich sehe grade, dass die Version von {get_template_vars}, die in http://www.cmsmadesimple.de/forum/viewtopic.php?id=337 vorgestellt wurde, und erst nicht lief, nun doch läuft und mir alle Variablen der aktuellen Seite mit Namen und Inhalt anzeigt.

Das ist doch schon etwas. Außerdem habe ich aus den angebotenen Templates alle Variablennamen, die dort auftauchen, rausgeschrieben, für das News-Modul.

Kann ich die irgendwo posten, damit andere Leute die Arbeit nicht nochmal machen müssen?

Offline

#4 05. November 2013 14:06

Klenkes
Server-Pate
Ort: 89428 Syrgenstein
Registriert: 17. Dezember 2010
Beiträge: 1.437

Re: Liste aller für Templates verfügbaren Variablen eines Moduls?

Für Module erhältst du ALLE Variablen, ob sie mit einem Wert belegt sind oder auch nicht, so:

Das wäre hier das Newsmodul. Egal ob Summary- oder Detailtemplate.

Die Variablen zu posten wäre sinnlos, das sie sich von Version zu Version auch unterscheiden können, und du ja auch deine eigenen Felder anlegen kannst.

Offline

#5 05. November 2013 14:09

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

Re: Liste aller für Templates verfügbaren Variablen eines Moduls?

Außerdem dachte ich, dass in der Modul-Hilfe des News-Moduls bereits alle Variablen drin stehen.
Zur Not mal die englische Hilfe anschauen. Die sollte meist am aktuellsten sein.


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

#6 05. November 2013 16:26

dlen
probiert CMS/ms aus
Registriert: 05. Februar 2011
Beiträge: 59

Re: Liste aller für Templates verfügbaren Variablen eines Moduls?

Hmm - ja.

In der Modulhilfe stehen die Aufrufparameter drin - nicht die Variablen. Wo einiges drinsteht ist das Details-Template. Ansonsten kann man sich die Variablen aus den ganzen Templates raussuchen.
Die sehen ungefähr so aus (mit einigen Anmerkungen):

Extrakt aus Summary-Template:

$cats	Kategorien	Array
$node
.depth
.prevdepth
.index
.count
.url
.news_category_name
$category_name
$pagecount	global
$pagenumber	global
$firstpage	global
$prevpage	global
$pagetext	global
$oftext	global 
$nextpage	global	
$lastpage	global
$items	global
$entry
->postdate	
->moreurl
->title
->author
->summary
->content
->extra
->extravalue
->fields
->type
->displayvalue
->name
->filelocation

Liste in Details-Template

Das entry - Objekt

id (integer)	The unique article id.
author_id (integer)   	The userid of the author who created the article.  This value may be negative to indicate an FEU userid.
title (string)   	The title of the article.
summary (text)   	The summary text (may be empty or unset).
content (text)	The content.
extra (string)   	The "extra" data associated with the article (may be empty or unset).
news_url (string)	The url segment associated with this article (may be empty or unset).
postdate (string)	A string representing the news article post date.  You may filter this through cms_date_format for different display possibilities.
startdate (string)= A string representing the date the article should begin to appear.  (may be empty or unset)
enddate (string) 	A string representing the date the article should stop appearing on the site (may be empty or unset).
category_id (integer) 	The unique id of the hierarchy level where this article resides (may be empty or unset)
status (string)  	either 'draft' or 'published' indicating the status of this article.
author (string)  	The username of the original author of the article.  If the article was created by frontend submission, this will attempt to retrieve the username from the FEU module.
authorname (string)   	The full name of the original author of the website. Only applicable if article was created by an administrator and that information exists in the administrators profile.
category (string)	The name of the category that this article is associated with.
canonical (string)	A full URL (prettified) to this articles detail view using defaults if necessary.
fields (associative)  	An associative array of field objects, representing the fields, and their values for this article.  See the information below on the field object definition.   In past versions of News this was a simple array, now it is an associative one.
customfieldsbyname	(deprecated) - A synonym for the 'fields' member
fieldsbyname	(deprecated) - A synonym for the 'fields' member
useexp (integer) 	A flag indicating wether this article is using the expiry information.
file_location (string)	A url containing the location where files attached the article are stored... the field value should be appended to this url.

Das entry->fields - Objekt

id (integer) 	The id of the field definition
name (string)	The name of the field
type (string)	The type of field
 textbox	einzeilige Textfeld
 checkbox	Kontrollkästchen
 textarea
 dropdown
 file
max_length (integer)	The maximum length of the field (applicable only to text fields)
item_order (integer)	The order of the field
public (integer)	A flag indicating wether the field is public or not
value (mixed)   	The value of the field.
displayvalue (mixed)	A displayable value for the field.  This is particularly useful in the case of dropdown fields.

Sonstige im Details-Template auftauchende

$extra_label	
$author_label
$return_url

Im Form-Template auftauchende

$error
$message
$startform
$titletext
$inputtitle
$categorytext
$inputcategory
$hide_summary_field
$summarytext
$input_summary
$contenttext
$inputcontent
$extratext
$inputextra
$startdatetext
$html_select_date
$startdateprefix
$startdate
$enddatetext
$enddateprefix
$enddate
$customfields
$onefield
name
field
$endform

Danke für die Anregung mit $entry. Sie liefert die Variablen, die zu einem Eintrag zugeordnet sind:


<pre>stdClass Object
(
    [author_id] => 1
    [author] => autor1
    [authorname] =>  
    [id] => 1
    [title] => News Module Installed
    [content] => 

The news module was installed. Exciting. This news article is not using the Summary field and therefore there is no link to read more. But you can click on the news heading to read only this article.

    [summary] => 

Hallo, hallo

Es wird bei Return ein Absatz erzeugt??

 

    [postdate] => 2013-10-30 13:01:13
    [startdate] => 
    [enddate] => 
    [create_date] => 2013-10-30 13:01:13
    [modified_date] => 2013-11-04 00:46:08
    [category] => General
    [fields] => 
    [fieldsbyname] => 
    [file_location] => http://mydomain.de/uploads/news/id1
    [link] => http://mydomain.de/index.php?mact=News,cntnt01,detail,0&cntnt01articleid=1&cntnt01returnid=65
    [titlelink] => News Module Installed
    [morelink] => weiterlesen
    [moreurl] => http://mydomain.de/index.php?mact=News,cntnt01,detail,0&cntnt01articleid=1&cntnt01returnid=65
)
1</pre>

Beitrag geändert von dlen (05. November 2013 16:36)

Offline