So kann jeder User seinem Gästebucheintrag noch ein Bild hinzufügen
Editiere folgende Dateien deiner Extension
./ext_tables.sql
füge ein
PHP-Code:
cr_image tinyblob NOT NULL,
um in deiner DB auch Platz für das Bild zu schaffen
./ext_emconf.php
füge ein
PHP-Code:
'uploadfolder' => 'uploads/tx_ttguest',
Damit der mir beim nächsten Update der Extension auch automatisch das Verzeichnis anlegt, wo die ganzen Bilder reinkommen.
./ext_typoscript_setup.txt
suche
füge hinzu
suche
PHP-Code:
postform.DataArray
füge hinzu
PHP-Code:
45.label = Bild:
45.type = data[tt_guest][NEW][cr_image]=file,25
Damit das ganze auch im Frontendformular mit drin ist.
suche
PHP-Code:
postform.no_cache=1
füge hinzu
PHP-Code:
theimage {
file.width=100
imageLinkWrap = 1
imageLinkWrap {
enable = 1
bodyTag (
marginwidth="2" marginheight="2">
)
wrap = <a href="javascript:close();"> | </a>
width = 640m
height = 640m
JSwindow = 1
JSwindow.newWindow = 1
JSwindow.expand = 4,4
}
}
Damit kannst du die Eigenschaften des Thumbnails im Guestbook steuern...bei mir wird das zB bei Mouseklick in nem neuen Fenster geöffnet.
./tca.php
ersetze komplett Datei mit
PHP-Code:
<?php
// ******************************************************************
// This is the standard TypoScript guestbook
// ******************************************************************
['tt_guest'] = Array (
'ctrl' => ['tt_guest']['ctrl'],
'interface' => Array (
'showRecordFieldList' => 'title,cr_name,cr_email,cr_image,note,www,hidden'
),
'columns' => Array (
'title' => Array (
'label' => 'LLL:EXT:lang/locallang_general.php:LGL.title',
'config' => Array (
'type' => 'input',
'size' => '40',
'max' => '256'
)
),
'note' => Array (
'label' => 'LLL:EXT:lang/locallang_general.php:LGL.note',
'config' => Array (
'type' => 'text',
'cols' => '40',
'rows' => '5'
)
),
'cr_name' => Array (
'label' => 'LLL:EXT:tt_guest/locallang_tca.php:tt_guest.cr_name',
'config' => Array (
'type' => 'input',
'size' => '40',
'eval' => 'trim',
'max' => '80'
)
),
'cr_image' => Array (
'label' => 'LLL:EXT:tt_guest/locallang_tca.php::tt_guest.cr_image',
"config" => Array (
"type" => "group",
"internal_type" => "file",
"allowed" => "gif,jpg,jpeg,png", // Allowed extensions
"max_size" => "1000", // Max 1000 kb pr. image
"uploadfolder" => "uploads/tx_ttguest",
"show_thumbs" => "1", // Yes, show thumbnails in backend
"size" => "3", // The image list box is 3 items high
"maxitems" => "6", // Max 6 images pr. record!
"minitems" => "0" // Min 0 images.
)
),
'cr_email' => Array (
'label' => 'LLL:EXT:tt_guest/locallang_tca.php:tt_guest.cr_email',
'config' => Array (
'type' => 'input',
'size' => '40',
'eval' => 'trim',
'max' => '80'
)
),
'www' => Array (
'exclude' => 1,
'label' => 'LLL:EXT:lang/locallang_general.php:LGL.www',
'config' => Array (
'type' => 'input',
'eval' => 'trim',
'size' => '20',
'max' => '256'
)
),
'hidden' => Array (
'exclude' => 1,
'label' => 'LLL:EXT:lang/locallang_general.php:LGL.hidden',
'config' => Array (
'type' => 'check',
'default' => '1'
)
)
),
'types' => Array (
'0' => Array('showitem' => 'hidden;;;;1-1-1, title;;;;3-3-3, note, cr_name, cr_email, cr_image, www')
)
);
?>
./pi/class.tx_ttguest.php
suche
PHP-Code:
while(list(,)=each()) {
// Passing data through stdWrap and into the markerArray
und überschreibe
PHP-Code:
->start(); // Set this->data to the current record tt_guest record.
=array();
//print_r();
=["theimage."];
["file"]="uploads/tx_ttguest/".["cr_image"];
["###POST_IMAGE###"] = ->IMAGE();
["###POST_TITLE###"] = ->stdWrap(->formatStr(["title"]), ["title_stdWrap."]);
["###POST_CONTENT###"] = ->stdWrap(->formatStr(["note"]), ["note_stdWrap."]);
["###POST_AUTHOR###"] = ->stdWrap(->formatStr(["cr_name"]), ["author_stdWrap."]);
["###POST_EMAIL###"] = ->stdWrap(->formatStr(["cr_email"]), ["email_stdWrap."]);
Jetzt passt du noch das Template an (zb pi/guest_template1.tmpl) und baust da irgendwo den Marker
HTML-Code:
###POST_IMAGE###
ein.
So, bis hierhin sollte alles funktionieren, bis auf das hochladen der Bilder im Frontend. Wenn nicht, hab ich irgendwas falsch beschrieben
Jetzt zum hochladen:
Nach dem Submit im Frontend wird die guest_submit.inc aufgerufen…..die muss natürlich auch geändert werden:
PHP-Code:
= Array["HTTP_POST_FILES"]["data"]["tmp_name"]["tt_guest"]["NEW"]["cr_image"];
= time()."_".Array["HTTP_POST_FILES"]["data"]["name"]["tt_guest"]["NEW"]["cr_image"];
move_uploaded_file(, "uploads/tx_ttguest/".);
->newData["tt_guest"]["NEW"]["cr_image"]=;
// print_r(->newData);
->execNEWinsert("tt_guest", ->newData["tt_guest"]["NEW"]);
So, wenn ich nix vergessen habe sollte es funktionieren. Hier ist jetzt aber noch keine Überprüfung auch Maximale-Uploadgröße drin. Das müsste dann auch in die guest_submit.inc rein, noch vor dem execNEWinsert, aber ich denk das kriegt ihr schon hin.
© Copyright consulting1x1