Results 1 to 5 of 5

Thread: Contao Framework Question

  1. #1
    User
    Join Date
    06-20-10.
    Posts
    64

    Default Contao Framework Question

    Is there any method in Contao, to display or obtain the ID of the current page?

    (Not the IDs of the elements on a page, but the ID of the page itself).

    Thank you!

  2. #2
    User
    Join Date
    07-26-09.
    Posts
    175

    Default Re: Contao Framework Question

    I guess it is
    [code=php:1ogcq3te]<span class="syntaxdefault">
    </span><span class="syntaxkeyword">global*</span><span class="syntaxdefault">$objPage</span><span class="syntaxkeyword">;
    </span><span class="syntaxdefault">$objPage</span><span class="syntaxkeyword">-></span><span class="syntaxdefault">id</span><span class="syntaxkeyword">;
    *</span><span class="syntaxdefault"></span>[/code:1ogcq3te]

  3. #3
    User
    Join Date
    06-20-10.
    Posts
    64

    Default Re: Contao Framework Question

    Thanks very much, that worked nicely.

    Is there something similar to get the current url too ?

    I tried $objPage->url; but that doesn't seem to exist

  4. #4
    Community-Moderator xchs's Avatar
    Join Date
    06-19-09.
    Posts
    1,287

    Default Re: Contao Framework Question

    Hi partisanentity,

    Quote Originally Posted by partisanentity
    Is there something similar to get the current url too ?
    The current URL you get via the Insert Tags :{{env:ath}}{{env::request}}

    http://www.contao.org/insert-tags.html
    Contao Community Moderator
    → Support options

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

    Default Re: Contao Framework Question

    Quote Originally Posted by partisanentity
    Thanks very much, that worked nicely.

    Is there something similar to get the current url too ?

    I tried $objPage->url; but that doesn't seem to exist
    take a look at the Environment object

    Please note that you can't call method directly because they are "protected", however the Environment class allows you to call its methods as property.
    Code:
    // inside a class that extends Controller
    // the import should not be needed
    // $this->import('Enviroment'); 
    // this will call the url() method of the Environment class, see the url above
    echo $this->Environment->url;
    Consulenza Contao CMS https://www.intco.it

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
  •