Results 1 to 4 of 4

Thread: Anchor links and tags

  1. #1
    New user
    Join Date
    12-04-12.
    Posts
    24

    Default Anchor links and tags

    Hello,

    I am trying to create a video library that will have anchors and links from an index. The index and the videos will be on the same page.

    I found this thread but am not sure how to insert into a page and what to change.

    On the fact that contao uses the base tag in HEAD
    HTML Code:
    <base href="http://example.org/">
    a hash like #myId isn't enough. You additionaly have to use the actual page (folder) name. For this to achieve you can use the insert tag {{env::request}} (what is this and what do I need from my site)
    Code:
    {{env::request}}#myId
    The rest is as in every HTML-page: your link
    HTML Code:
    <a href="my-page.html#myId">myId</a>
    leads to an element with the ID "myId" on that page.

    Here is the link https://community.contao.org/en/show...-to-link-Image

    I'm sure it is very simple but I could use some direction.

    Thanks for you help in advance.
    Don

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

    Default

    Please show a link to a page so we can see what you have done so far.

    {{env::request}} is an insert tag that gets resolved from Contao with the actual page alias e.g. "contact.html". You can use it within the BE or in Templates.
    Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
    Amazon wishlist

  3. #3
    User
    Join Date
    05-21-18.
    Posts
    126

    Default

    Quote Originally Posted by Don View Post
    Hello,

    I am trying to create a video library that will have anchors and links from an index. The index and the videos will be on the same page.

    I found this thread but am not sure how to insert into a page and what to change.

    On the fact that contao uses the base tag in HEAD
    HTML Code:
    <base href="http://example.org/">
    a hash like #myId isn't enough. You additionaly have to use the actual page (folder) name. For this to achieve you can use the insert tag {{env::request}} (what is this and what do I need from my site)
    Code:
    {{env::request}}#myId
    The rest is as in every HTML-page: your link
    HTML Code:
    <a href="my-page.html#myId">myId</a>
    leads to an element with the ID "myId" on that page.

    Here is the link https://community.contao.org/en/show...-to-link-Image

    I'm sure it is very simple but I could use some direction.

    Thanks for you help in advance.
    Don

    If i understand u correctly u want anchor links on the same page.
    u need to add
    Code:
    href="<?php echo \Environment::get('url'); ?>#anchor"
    #anchor. Try this

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

    Default

    Quote Originally Posted by rawelja View Post
    Code:
    href="<?php echo \Environment::get('url'); ?>#anchor"
    Yes, this is the better way for templates, but you also can use insert tags in templates. You can not use PHP code in BE.

    An it needs a correction
    Code:
    href="<?= \Environment::get('relativeRequest') ?>#anchor"
    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
  •