Ergebnis 1 bis 5 von 5

Thema: tl_page um ein Feld erweitern und in der fe_page ausgeben

  1. #1
    Contao-Nutzer
    Registriert seit
    29.05.2013.
    Beiträge
    81

    Standard tl_page um ein Feld erweitern und in der fe_page ausgeben

    Hi Leute,

    ich habe ein kleine Problem. Ich möchte die tl_page um ein Feld erweitern z.B. test. Dieses feld bekomme ich auch im BE angezeigt...doch nun möchte ich es auch im Template fe_page ausgeben doch es ist einfach nicht da?

    dca:
    PHP-Code:
    <?php
    /**
     * sv-bootstrap-contao
     * @author     Sebastian Vogt
     * @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL
     */


    foreach($GLOBALS['TL_DCA']['tl_page']['palettes'] as $name => $palette){
        if(
    $name === '__selector__'){
            continue;
        }
        
    $GLOBALS['TL_DCA']['tl_page']['palettes'][$name] = str_replace
        
    (
            
    '{publish_legend}',
            
    '{bootstrapContao_legend:hide},test;{publish_legend}',
            
    $palette
        
    );
    }






    $GLOBALS['TL_DCA']['tl_page']['fields']['test'] = array
    (
                
    'label'                   => &$GLOBALS['TL_LANG']['tl_page']['test'],
                
    'exclude'                 => true,
                
    'inputType'               => 'text',
                
    'search'                  => true,
                
    'eval'                    => array('mandatory'=>false'maxlength'=>255'decodeEntities'=>true),
                
    'sql'                     => "varchar(255) NOT NULL default ''"
    );
    fe_page
    PHP-Code:
    <?php
    /**
     * sv-bootstrap-contao
     * @author     Sebastian Vogt
     * @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL
     */
    ?>
    <?php

    define
    ("THEME_PATH""files/themes/bootstrap-contao/");
    define("ASSETS_PATH"THEME_PATH "assets/");
    define("BOOTSTRAP_PATH"THEME_PATH "bootstrap/");

    define("MODULE_PATH""system/modules/sv-bootstrap-contao/");






    $GLOBALS['TL_HEAD'][] = '<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">';
    $GLOBALS['TL_HEAD'][] = '<link href="files/themes/bootstrap-contao/bootstrap/dist/css/bootstrap.css" rel="stylesheet">';
    $GLOBALS['TL_BODY'][] ='<script src="files/themes/bootstrap-contao/bootstrap/dist/js/bootstrap.js"></script>';
    if(
    $this->layout->bscAddBlueimp){
        
    $GLOBALS['TL_HEAD'][] = '<link rel="stylesheet" href="system/modules/sv-bootstrap-contao/assets/js/blueimp-gallery/css/blueimp-gallery.min.css">';
        
    $GLOBALS['TL_BODY'][] = '<script src="system/modules/sv-bootstrap-contao/assets/js/blueimp-gallery/js/blueimp-gallery.min.js"></script>';
        
    $GLOBALS['TL_BODY'][] = '<script src="system/modules/sv-bootstrap-contao/assets/js/blueimp-gallery/js/jquery.blueimp-gallery.min.js"></script>';
    }
    $GLOBALS['TL_BODY'][] = '<script src="files/themes/bootstrap-contao/bootstrap/js/app.js"></script>';


    ?>
    <!DOCTYPE html>
    <html lang="<?php echo $this->language?>">
    <head>

        <meta charset="<?php echo $this->charset?>">
        <title><?php echo $this->pageTitle?> - <?php echo $this->mainTitle?></title>
        <base href="<?php echo $this->base?>">

        <meta name="robots" content="<?php echo $this->robots?>">
        <meta name="description" content="<?php echo $this->description?>">
        <meta name="keywords" content="<?php echo $this->keywords?>">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">

        <?php echo $this->viewport?>
        <?php echo $this->framework?>
        <?php echo $this->stylesheets?>
        <?php echo $this->mooScripts?>
        <?php echo $this->head?>

        <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
        <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
        <![endif]-->

    </head>
    <body id="top"
          class="{{ua::class}}<?php if ($this->class): ?> <?php echo $this->class?><?php endif; ?>"<?php if ($this->onload): ?> onload="<?php echo $this->onload?>"<?php endif; ?><?php if($this->bscBackgroundImage): ?> style="backgroundImage:url('<?php echo $this->bscBackgroundImage ?>'); background-repeat: no-repeat; background-size: cover;"<?php endif; ?>>





    <div id="wrapper">
        <header id="header">
            <div class="inside">
                <?php echo $this->header?>
            </div>
        </header>


        <div id="container" class="container">
            <div class="inside row">
            <div>
                <?php echo $this->test?>
            </div>

                <div id="main" class="col-sm-8">
                    <div class="inside row">
                        <?php echo $this->main?>
                    </div>
                </div>

                <div class="divider visible-xs col-xs-12">
                    <hr/>
                </div>

                <aside id="right" class="col-sm-4">
                    <div class="inside row">
                        <div class="col-sm-12">
                            <?php echo $this->right?>
                        </div>
                    </div>
                </aside>
            </div>
        </div>


        <footer id="footer">
            <div class="inside">
                <?php echo $this->footer?>
            </div>
        </footer>
    </div>

    <?php if($this->layout->bscAddBlueimp): ?>
        <div id="blueimp-gallery" class="blueimp-gallery blueimp-gallery-controls">
            <div class="slides"></div>
            <h3 class="title"></h3>
            <a class="prev">‹</a>
            <a class="next">›</a>
            <a class="close">×</a>
            <a class="play-pause"></a>
            <ol class="indicator"></ol>
        </div>
    <?php endif; ?>


    <?php echo $this->mootools?>

    <?php if (!$this->disableCron): ?>
        <script>
            <?php if ($this->layout->addJQuery): ?>
            setTimeout(function () {
                jQuery.ajax("system/cron/cron.txt", {complete: function (e) {
                    var t = e.responseText || 0;
                    parseInt(t) < Math.round(+(new Date) / 1e3) -<?php echo $this->cronTimeout?> && jQuery.ajax("system/cron/cron.php")
                }})
            }, 5e3)
            <?php else: ?>
            setTimeout(function () {
                (new Request({url: "system/cron/cron.txt", onComplete: function (e) {
                    e || (e = 0), parseInt(e) < Math.round(+(new Date) / 1e3) -<?php echo $this->cronTimeout?> && (new Request({url: "system/cron/cron.php"})).get()
                }})).get()
            }, 5e3)
            <?php endif; ?>
        </script>
    <?php endif; ?>
    </body>
    </html>

    was mach ich falsch???

  2. #2
    Community-Moderator
    Wandelndes Contao-Lexikon
    Avatar von Spooky
    Registriert seit
    12.04.2012.
    Ort
    Scotland
    Beiträge
    34.197
    Partner-ID
    10107

    Standard

    Nimm entweder
    PHP-Code:
    echo $GLOBALS['objPage']->test
    oder
    PHP-Code:
    global $objPage;
    echo 
    $objPage->test
    Im fe_page Template hast du mit $this die Variablen des Seitenlayouts, nicht der Page.

  3. #3
    Contao-Nutzer
    Registriert seit
    29.05.2013.
    Beiträge
    81

    Standard

    Ok Danke schön... das habe ich soweit hinbekommen....was ich aber eigentlich will ist ein background image einzufügen nun brauch ich ja den pfad zum Bild....aber den bekomm ich irgendwie nicht richtig ausgelesen....

    dca
    PHP-Code:
    <?php
    /**
     * sv-bootstrap-contao
     * @author     Sebastian Vogt
     * @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL
     */


    foreach($GLOBALS['TL_DCA']['tl_page']['palettes'] as $name => $palette){
        if(
    $name === '__selector__'){
            continue;
        }
        
    $GLOBALS['TL_DCA']['tl_page']['palettes'][$name] = str_replace
        
    (
            
    '{publish_legend}',
            
    //'{bootstrapContao_legend:hide},iconClass,onlyIcon,bscHeadline,bscDivider;{publish_legend}',
            
    '{bootstrapContao_legend:hide},bscDivider,onlyIcon,iconClass,bscHeadline,bscBackgroundImage,test;{publish_legend}',
            
    $palette
        
    );
    }






    $GLOBALS['TL_DCA']['tl_page']['fields']['iconClass'] = array
    (

        
    'label'                   => &$GLOBALS['TL_LANG']['tl_page']['iconClass'], /* Hier geben wir die Variable an, welche später in der Language-Datei/n definiert wird. */
        
    'exclude'                 => false,
        
    'search'                  => true/*das Feld kann im Backend durchsucht werden*/
        
    'inputType'               => 'text'/* Feldtyp */
        
    'eval'                    => array('mandatory'=>false'maxlength'=>255,'tl_class'=>'w50 m12'), /*evaluation, siehe offizielle Contao-Manual */
        
    'sql'                     => "varchar(255) NOT NULL default ''" /* schließlich die SQL- Vorgaben */

    );

    $GLOBALS['TL_DCA']['tl_page']['fields']['onlyIcon'] = array
    (

        
    'label'                   => &$GLOBALS['TL_LANG']['tl_page']['onlyIcon'],
        
    'exclude'                 => true,
        
    'inputType'               => 'checkbox',
        
    'eval'                    => array('tl_class' => 'w50 m12'),
        
    'sql'                     => "char(1) NOT NULL default ''"

    );

    $GLOBALS['TL_DCA']['tl_page']['fields']['bscHeadline'] = array
    (

        
    'label'                   => &$GLOBALS['TL_LANG']['tl_page']['bscHeadline'],
        
    'exclude'                 => true,
        
    'search'                  => true,
        
    'inputType'               => 'text',
        
    'eval'                    => array('tl_class' => 'w50 m12''maxlength' => 255),
        
    'sql'                     => "char(255) NOT NULL default ''"

    );





    $GLOBALS['TL_DCA']['tl_page']['fields']['bscDivider'] = array
    (

        
    'label'                   => &$GLOBALS['TL_LANG']['tl_page']['bscDivider'],
        
    'exclude'                 => true,
        
    'inputType'               => 'checkbox',
        
    'eval'                    => array('tl_class' => 'w50 m12'),
        
    'sql'                     => "char(1) NOT NULL default ''"

    );


    // bscBackgroundImage
    $GLOBALS['TL_DCA']['tl_page']['fields']['bscBackgroundImage'] = array
    (
        
    'label'                   => &$GLOBALS['TL_LANG']['tl_page']['bscBackgroundImage'],
        
    'exclude'                 => true,
        
    'inputType'               => 'fileTree',
        
    'eval'                    => array('filesOnly'=>true'fieldType'=>'radio''mandatory'=>false'tl_class'=>'clr'),
        
    'sql'                     => "binary(16) NULL"
    );
    fe_page
    PHP-Code:
    <?php
    /**
     * sv-bootstrap-contao
     * @author     Sebastian Vogt
     * @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL
     */
    ?>
    <?php

    define
    ("THEME_PATH""files/themes/bootstrap-contao/");
    define("ASSETS_PATH"THEME_PATH "assets/");
    define("BOOTSTRAP_PATH"THEME_PATH "bootstrap/");

    define("MODULE_PATH""system/modules/sv-bootstrap-contao/");

    global 
    $objPage;





    $GLOBALS['TL_HEAD'][] = '<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">';
    $GLOBALS['TL_HEAD'][] = '<link href="files/themes/bootstrap-contao/bootstrap/dist/css/bootstrap.css" rel="stylesheet">';
    $GLOBALS['TL_BODY'][] ='<script src="files/themes/bootstrap-contao/bootstrap/dist/js/bootstrap.js"></script>';
    if(
    $this->layout->bscAddBlueimp){
        
    $GLOBALS['TL_HEAD'][] = '<link rel="stylesheet" href="system/modules/sv-bootstrap-contao/assets/js/blueimp-gallery/css/blueimp-gallery.min.css">';
        
    $GLOBALS['TL_BODY'][] = '<script src="system/modules/sv-bootstrap-contao/assets/js/blueimp-gallery/js/blueimp-gallery.min.js"></script>';
        
    $GLOBALS['TL_BODY'][] = '<script src="system/modules/sv-bootstrap-contao/assets/js/blueimp-gallery/js/jquery.blueimp-gallery.min.js"></script>';
    }
    $GLOBALS['TL_BODY'][] = '<script src="files/themes/bootstrap-contao/bootstrap/js/app.js"></script>';


    ?>
    <!DOCTYPE html>
    <html lang="<?php echo $this->language?>">
    <head>

        <meta charset="<?php echo $this->charset?>">
        <title><?php echo $this->pageTitle?> - <?php echo $this->mainTitle?></title>
        <base href="<?php echo $this->base?>">

        <meta name="robots" content="<?php echo $this->robots?>">
        <meta name="description" content="<?php echo $this->description?>">
        <meta name="keywords" content="<?php echo $this->keywords?>">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">

        <?php echo $this->viewport?>
        <?php echo $this->framework?>
        <?php echo $this->stylesheets?>
        <?php echo $this->mooScripts?>
        <?php echo $this->head?>

        <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
        <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
        <![endif]-->

    </head>
    <body id="top"
          class="{{ua::class}}<?php if ($this->class): ?> <?php echo $this->class?><?php endif; ?>"<?php if ($this->onload): ?> onload="<?php echo $this->onload?>"<?php endif; ?><?php if($objPage->bscBackgroundImage): ?> style="backgroundImage:url('<?php echo deserialize($objPage->bscBackgroundImagetrue); ?>'); background-repeat: no-repeat; background-size: cover;"<?php endif; ?>>





    <div id="wrapper">
        <header id="header">
            <div class="inside">
                <?php echo $this->header?>
            </div>
        </header>


        <div id="container" class="container">
            <div class="inside row">
                <div>
                    <?php
                    $objFile 
    = \FilesModel::findByPk($objPage->bscBackgroundImage);
                    echo 
    $objFile;
                    
    ?>
                </div>
                <div id="main" class="col-sm-8">
                    <div class="inside row">
                        <?php echo $this->main?>
                    </div>
                </div>

                <div class="divider visible-xs col-xs-12">
                    <hr/>
                </div>

                <aside id="right" class="col-sm-4">
                    <div class="inside row">
                        <div class="col-sm-12">
                            <?php echo $this->right?>
                        </div>
                    </div>
                </aside>
            </div>
        </div>


        <footer id="footer">
            <div class="inside">
                <?php echo $this->footer?>
            </div>
        </footer>
    </div>

    <?php if($this->layout->bscAddBlueimp): ?>
        <div id="blueimp-gallery" class="blueimp-gallery blueimp-gallery-controls">
            <div class="slides"></div>
            <h3 class="title"></h3>
            <a class="prev">‹</a>
            <a class="next">›</a>
            <a class="close">×</a>
            <a class="play-pause"></a>
            <ol class="indicator"></ol>
        </div>
    <?php endif; ?>


    <?php echo $this->mootools?>

    <?php if (!$this->disableCron): ?>
        <script>
            <?php if ($this->layout->addJQuery): ?>
            setTimeout(function () {
                jQuery.ajax("system/cron/cron.txt", {complete: function (e) {
                    var t = e.responseText || 0;
                    parseInt(t) < Math.round(+(new Date) / 1e3) -<?php echo $this->cronTimeout?> && jQuery.ajax("system/cron/cron.php")
                }})
            }, 5e3)
            <?php else: ?>
            setTimeout(function () {
                (new Request({url: "system/cron/cron.txt", onComplete: function (e) {
                    e || (e = 0), parseInt(e) < Math.round(+(new Date) / 1e3) -<?php echo $this->cronTimeout?> && (new Request({url: "system/cron/cron.php"})).get()
                }})).get()
            }, 5e3)
            <?php endif; ?>
        </script>
    <?php endif; ?>
    </body>
    </html>
    steh grad völlig aufm schlauch dabei ist doch heut garnicht montag

  4. #4
    Community-Moderator
    Wandelndes Contao-Lexikon
    Avatar von Spooky
    Registriert seit
    12.04.2012.
    Ort
    Scotland
    Beiträge
    34.197
    Partner-ID
    10107

    Standard

    In $objPage->bscBackgroundImage steht die UUID des Bildes. Du musst dir nun das entsprechende Objekt aus der Datenbank holen um an den Pfad zu kommen:
    PHP-Code:
    $objFile = \FilesModel::findById$objPage->bscBackgroundImage );
    echo 
    $objFile->path

  5. #5
    Contao-Nutzer
    Registriert seit
    29.05.2013.
    Beiträge
    81

    Standard

    Danke.... heut ist irgendwie nicht mein Tag.
    hatte das path vergessen.....

Aktive Benutzer

Aktive Benutzer

Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)

Lesezeichen

Lesezeichen

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •