Results 1 to 3 of 3

Thread: Nested Inserttags

  1. #1
    New user americocs's Avatar
    Join Date
    08-31-09.
    Location
    Brasil
    Posts
    9

    Default Nested Inserttags

    Hi,

    I'm trying to find a solution to create individual member content, that would be shown inside the same private page. After extensive search in this forum I think the best solution would be using the inserttags {{insert_article::*}} and {{user::username}}, like {{insert_article::{{user::username}}}}. If this worked, it could show one article per member after login, using just one page (provided that there is an article with the same alias as the member name).

    I tried using a php file with {{insert_article::<?php echo $this->replaceInsertTags('{{user::username}}'); ?>}}, and I get the correct result {{insert_article::userxxx}}. The problem is that this new inserttag isnt parsed in the front end, and just shows there like {{insert_article::userxxx}} without bringing the correct article.

    On the other hand, if I put {{insert_article::userxxx}} as a text content element, it works and brings the article aliased "userxxx". But I want to bring the article related to the corresponding logged in member.

    Any thoughts on how to do that?

    thanks in advance

  2. #2
    User
    Join Date
    06-19-09.
    Posts
    328

    Default Re: Nested Inserttags

    Quote Originally Posted by americocs
    Hi,

    I'm trying to find a solution to create individual member content, that would be shown inside the same private page. After extensive search in this forum I think the best solution would be using the inserttags {{insert_article::*}} and {{user::username}}, like {{insert_article::{{user::username}}}}. If this worked, it could show one article per member after login, using just one page (provided that there is an article with the same alias as the member name).

    I tried using a php file with {{insert_article::<?php echo $this->replaceInsertTags('{{user::username}}'); ?>}}, and I get the correct result {{insert_article::userxxx}}. The problem is that this new inserttag isnt parsed in the front end, and just shows there like {{insert_article::userxxx}} without bringing the correct article.

    On the other hand, if I put {{insert_article::userxxx}} as a text content element, it works and brings the article aliased "userxxx". But I want to bring the article related to the corresponding logged in member.

    Any thoughts on how to do that?
    The zedseries_lib extension features a "Content Template" content element that let you add a template as content element with support for insert-tags.


    Anyway if you only need to know the current loggedin member username you can use the following code:

    Code:
    // inside the template
    
    <?php
    if (!FE_USER_LOGGED_IN) {
       // there is no member logged in
        return;
    }
    $this->import('FrontendUser');
    ?>
     {{insert_article::<?php echo $this->FrontendUser->username; ?>}}
    hope this helps
    Consulenza Contao CMS https://www.intco.it

  3. #3
    Experienced user
    Join Date
    01-12-10.
    Posts
    814

    Default Re: Nested Inserttags

    What about trying the function you used twice? The inner function must be parsed first...
    Code:
    <?php echo $this->replaceInsertTags('{{insert_article::' . $this->replaceInsertTags('{{user::username}}') . '}}'); ?>
    I'm assuming the page you show the content on is protected, so a user will always be logged in? In that case a more memory/time efficient way would be:
    Code:
    <?php
    $this->import('FrontendUser');
    echo $this->replaceInsertTags('{{insert_article::' . $this->FrontendUser->username . '}}');
    ?>
    Or even more efficient:
    Code:
    <?php
    $this->import('FrontendUser');
    echo $this->replaceInsertTags(ltrim($this->getArticle($this->FrontendUser->username, false, true)));
    It doesn't matter where you put this code, either in the template or the php file. Both are parsed as php.

    ps, I'm unable to test if the code is correct atm... Please let me know if you had any trouble, or success!

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
  •