Results 1 to 11 of 11

Thread: The dma_elementgenerator

  1. #1

    Default The dma_elementgenerator

    I just stumbled upon the extension "dma_elementgenerator" and seems to be just what I need ... But when I build a dma content element e.g. lets say a content element to describe a music album: artist, album and a album cover. I get the artist and the album looking fine, but the album cover shoots out the string to the image only and not a html <img> tag with the string. I can of course make another template for the image itself but then I have to drop in two content elements for each album Is there some way around this?

    Any help is appreciated :-)

    Thanks!

  2. #2
    Experienced user
    Join Date
    08-21-09.
    Posts
    563

    Default Re: The dma_elementgenerator

    Much like the Catalog, the Element Generator extension relies heavily upon your own ability to customize your templates in order to get things looking exactly how you want. If you rely only on the provided default templates, you'll find things much more limiting.

    So you need to make your own "dma_eg_" template, and in that template, along with your other fields, you'd add an <img> tag, setting the src to that string.
    Brian

  3. #3

    Default Re: The dma_elementgenerator

    I´m a bit in the dark here. Can you give an examples of this? How do I differentiate between the values?
    I tried this (see below) but this of course just duplicates the value ...

    Code:
    <li class="<?php echo $this->class; ?>">
      <span class="label"><?php echo $this->label ?></span>
      <span class="value"><?php echo $this->value ?></span>
      [img]<?php echo $this->value ?>[/img]
    Sorry for being a complete newbie here

  4. #4
    Experienced user
    Join Date
    08-21-09.
    Posts
    563

    Default Re: The dma_elementgenerator

    Sure...

    First off, comment everything else out in your custom "dma_eg_" template, and instead put this in there:

    Code:
    <pre><?php $this->showTemplateVars(); ?></pre>
    Then look at it again in your browser. You should see a block of PHP gibberish. Send me that gibberish in a reply (or send a link where I can see it).

    The reason is that the code to use depends on how you've defined your custom fields -- they each have a specific name/label. And we need to know that to customize the template.

    In order to keep things generic enough that it'll work out of the box, The Element Generator (just like the Catalog) has a VERY basic default template -- it just says "loop through all the fields -- I don't care what they are -- and spit out the labels and values for each". This way at least something is output by default.

    But in both cases the real power of these extensions come when you know how to plug in these field values exactly where you want into a custom template.
    Brian

  5. #5

    Default Re: The dma_elementgenerator

    Here comes gibberish :-)

    Code:
    Array
    (
        [contentElement] => 1
        [articleID] => 1
        [articleTitle] => Homepage
        [articleAlias] => homepage
        [elements] => Array
            (
                [artist] => Metallica
                [album] => Fade To Black
                [album_cover] => tl_files/music_academy/admin.gif
            )
    
        [labels] => Array
            (
                [artist] => Artist
                [album] => Album
                [album_cover] => Album cover
            )
    
        [classes] => Array
            (
                [artist] => text
                [album] => text
                [album_cover] => image fileTree
            )
    
        [fields] => Artist Metallica
    #
    
      
    # Album Fade To Black
    
      
    # Album cover tl_files/music_academy/admin.gif
    
      
    
        [style] => 
        [cssID] => 
        [class] => ce_dma_eg_1
        [headline] => 
        [hl] => h1
    )

  6. #6
    Experienced user
    Join Date
    08-21-09.
    Posts
    563

    Default Re: The dma_elementgenerator

    OK, so here's an oversimplified example of how you'd display an album. Of course your HTML will vary depending on what you want, but this should give you an idea of how to translate that gibberish into something you want.

    Code:
    <div class="item">
    [img]<?php echo $this->elements['album_cover']; ?>[/img]elements['album']; ?> by <?php echo $this->elements['artist']; ?>" />
    <h1><?php echo $this->elements['artist']; ?></h1>
    <h2><?php echo $this->elements['album']; ?></h2>
    </item>
    Comparing that example to the code you pasted, you can similarly grab other potentially useful stuff, like...

    The "Artist" Label:
    Code:
    <?php echo $this->labels['artist']; // Will output "Artist" ?>
    The CSS class assigned to the album cover:
    Code:
    <?php echo $this->classes['album_cover']; // Will output "image fileTree" ?>
    Or even the article's title that the content element is in, if for some reason you'd want that:
    Code:
    <?php echo $this->articleTitle; // Will output "Homepage" ?>
    Does that help at all? Let me know if you have any more questions. This is the kind of stuff I wish was out there and easily findable when I was starting out...
    Brian

  7. #7

    Default Re: The dma_elementgenerator

    Ah! Thank you so much, makes perfect sense. Looking forward to dig into this! Great extension :D

  8. #8
    New user
    Join Date
    07-16-09.
    Location
    Lausanne, Switzerland
    Posts
    8

    Default Re: The dma_elementgenerator

    I wish that your extension provide a way to create download links for files. Actually, I had to "hack" the file "DMAElementGenerator.php" to correctly send the file to the browser :

    Code:
      public function generate($data)
      {
        /* MY CODE: begin */
        // Send file to the browser
        $arrData = deserialize($data->dma_eg_data);
        if (strlen($this->Input->get('file', true)) && $this->Input->get('file', true) == $arrData['filename'])
        {
          $this->sendFileToBrowser($this->Input->get('file', true));
        }
        /* MY CODE: end */
        return $this->compile($data);
    }
    Moreover, I had to "hack" the function "compile", and the template "dma_egfield_default.xhtml". You can see here what I got, in the last accordion.

  9. #9
    Experienced user
    Join Date
    08-21-09.
    Posts
    563

    Default Re: The dma_elementgenerator

    Do you know that you can create custom templates for this extension (like just about everything)?

    You should be able to create your own template in your templates or theme folder (starting with 'dma_') and put pretty much all of that code in it. That way you won't have to hack any core files.
    Brian

  10. #10
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: The dma_elementgenerator

    You can also force a pdf (or any file) to download rather than open via .htaccess

  11. #11

    Default Re: The dma_elementgenerator

    Another question ...

    I have made an content element with the DMA_elementgenerator end everything works fine except my checkboxes. I have made a checkbox which the client can tick to get round corners on the element by giving the element a class. But when I check it and click "save" it removes the tick. Does anyone know why and how to avoid this?

    Thanks,
    Christian

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •