Results 1 to 4 of 4

Thread: How to ignore current item in sidebar newslist?

  1. #1
    New user
    Join Date
    06-20-09.
    Posts
    8

    Frage How to ignore current item in sidebar newslist?

    Hi,

    I've a very simple problem but don't know enough about Contao internals to code it...

    I have a newsreader that prints the item and a sidebar with all other current news stories listed in it. I want to exclude the item printed in full by the newsreader from the sidebar list so that you don't see it twice. I'm thinking it should be just a simple case of adding in an IF statement comparing the alias to the parameter supplied to the newsreader module, but I don't know how to write this, other than kludging it myself by looking at $_GET.

    Can anyone help?!!

    Thanks in advance

    Bluesolarwater.

  2. #2
    User Andreas's Avatar
    Join Date
    07-11-09.
    Location
    Mönchengladbach
    Posts
    499

    Default

    Don't use $_GET within Contao. Use
    PHP Code:
    \Input::get('key');
    \
    Input::get('auto_item'); 
    You also can get page properties
    PHP Code:
    global $objPage;
    echo 
    $objPage-alias;
    dump($objPage); 
    Or with a Model (Maybe you will get some different values with $objPage and \PageModel. Consider that the news detail pages are not stored within DB.tl_page.)
    PHP Code:
    global $objPage;
    $pageModelObject = \PageModel::findByPk($objPage->id);
    echo 
    $pageModelObject->alias;
    dump($pageModelObject); 
    You also easily can find a news Model bei page alias
    PHP Code:
    $pageAlias = \Input::get('auto_item');
    $newsModelObj = \NewsModel::findByAlias($pageAlias);

    // Within your list template
    if($this->id === $newsModelObj->id)
    {

    All untested.
    Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
    Amazon wishlist

  3. #3
    New user
    Join Date
    06-20-09.
    Posts
    8

    Default

    Brilliant, thank you Andreas. That's enough info for me to figure out the rest on my own. Thanks for taking the time to explain this. Hopefully some other people will be helped too.

  4. #4
    User Andreas's Avatar
    Join Date
    07-11-09.
    Location
    Mönchengladbach
    Posts
    499

    Default

    You're welcome

    Edit: Oops, sorry, I forgot:
    PHP Code:
    $this->showTemplateVars(); // prints the template variables

    // or use this
    dump($this->arrData); 
    Last edited by Andreas; 07/22/2017 at 16:38.
    Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
    Amazon wishlist

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
  •