Kentico - Adding an anchor tag in a repeater transformation - tabs

I have an Accordion Tab repeater that I would like to add an anchor tag to each unique title within the transformation.
Here is my code:
<li>
<a href="#tab-<%# DataItemIndex+1%>-<%# Container.Parent.Parent.ClientID %>" title="<%# Eval("Title") %>">
<span class="tab-item-title"><%# Eval("Title") %></span>
<span class="ui-icon"></span>
<%# String.IsNullOrEmpty(Eval<string>("MainText")) ? "" : "<div class=\"tab-item-subtitle\">" + Eval("MainText") + "</div>" %>
</a>
</li>
I tried adding:
<a id="<%# Eval("AnchorLinkName") %>" name="<%# Eval("AnchorLinkName") %>"></a>,
but it didnt work.

No need to post this in both the DevNet and SO. The DevNet automatically includes SO posts tagged as "kentico". Reference original answer here:
https://devnet.kentico.com/questions/adding-an-anchor-tag-in-a-repeater-transformation
Typically what you do in this case is have a datasource web part on the page and specify the necessary fields (where, page types, order by, etc.). You take note of the datasources name and add that to two repeaters on the page. One repeater is or your anchor link navigation and the other is the actual content you wish to display (link to).
One thing to note, is the anchor link needs to be a URL friendly value. So something with spaces or un-encoded URL values will NOT work.
In your navigation repeater (where you link FROM), you'll need something like the following in the transformation:
<li>
<%# Eval("DocumentName") %>
</li>
In your listing repeater (where you link TO), you'll need something like the following in the transformation:
<div class="faq-item" id="faq-<%# Eval("DocumentID") %>">
... your content here
</div>
Reference W3Schools Bookmarks

Related

Semantic-UI - Links / A Tags / URLs Inside Semantic Ui Dropdown Menu Do Not Work

I am working with Semantic UI in a rails project and wanted to create a dropdown menu with items that would link to other view pages. Most of the problems i've seen with the dropdown stemmed from users not initializing the dropdown menu which I was able to do.
Here's my code:
<div class="ui floating dropdown button">
Course<i class="dropdown icon"></i>
<div class="menu">
<% #topics.each { |topic| %>
<a class="item" href="articles/<%= topic.id %>">
<span class="text"> <%= topic.name %></span>
</a>
<% } %>
</div>
</div>
Different things i've tried:
Creating a separate hardcoded links / a tags like <a href="articles/4"> outside of the dropdown menu. This creates a working link and directs me to the article show view page with the id of 4.
Changed the wrapping 's class as "ui floating dropdown item" as well
I've also looked up other users' posts that shows they have the same exact problem. But when i try their solution, my dropdown menu items still do not work and i'm not sure what i'm doing wrong. Here are their posts:
https://github.com/Semantic-Org/Semantic-UI/issues/3234
https://github.com/Semantic-Org/Semantic-UI/issues/453
The two most important things seem to be:
Not putting the dropdown class definition as part of an anchor tag (inserting an anchor tag inside an anchor tag in the dropdown menu)
Not surrounding each anchor tags with their own <div class="items"> tags but to integrate them into one line like <a class="item" href="#"> # </a>
Can anyone help me understand what i might be overlooking? Let me know if i left out any critical information, would love to update the post with the relevant data right away, thank you!
After doing more and more research, I came to the conclusion that the links were not working in my semantic-ui dropdown menu because of some code, most likely Javascript, that i had inserted before.
Of course, i ruled this way out of the realm of possibility because there was no way i would forget about such code but i decided to go through all of my .js files just in case.
Lo and behold, i had a jQuery selector return false when a .item was being clicked...
I felt really silly and i didnt want to believe it at first but if you're having this problem and you've checked everything else like i have, it's probably your javascript!

Getting a link to go to a specific section on another page

I have a link on one page that needs to go to a different page, but load to a specific section on that other page.
I have done this before with bootstrap but they take all the 'coding' out of it, so I need to know how to do from scratch. Here is the markup I have based on this link (not the best resource, I know): http://www.w3schools.com/html/html_links.asp
**Page One**
<a href="/academics/page.html#timeline> Click here </a>
**Page I am linking to**
<div id="timeline" name="timeline"> ... </div>
Can I do this with just HTML, or do I need some JavaScript? If I need to do it via JS, it needs to be on the target page, right?
I believe the example you've posted is using HTML5, which allows you to jump to any DOM element with the matching ID attribute. To support older browsers, you'll need to change:
<div id="timeline" name="timeline" ...>
To the old format:
<a name="timeline" />
You'll then be able to navigate to /academics/page.html#timeline and jump right to that section.
Also, check out this similar question.
You can simply use
<a href="directry/filename.html#section5" >click me</a>
to link to a section/id of another page by
To navigate to a section of another page use:
<a href="example.html#example-section>name-of-link</a>
The example.html would be the page you want to go to, and the #example-section would be the name of the id on that page that you want to navigate to.
To link from a page to another section of the page, I navigate through the page depending on the page's location to the other, at the URL bar, and add the #id. So what I mean;
This takes you #the_part_that_you_want at the page before
I tried the above answer - using page.html#ID_name it gave me a 404 page doesn't exist error.
Then instead of using .html, I simply put a slash / before the # and that worked fine. So my example on the sending page between the link tags looks like:
El Chorro
Just use / instead of .html.
To link from a page to another section just use
my first div

How to use an HTML # anchor in a dynamic URL

I want to link to a section of a dynamic page using the # anchor. Something like this:
<a href=page.php?id=3#section-name>LINK</a>
It didn't work. What is the right way to do it?
I'm not using a direct link, but a redirect like header("Location:page.php?id=3#section-name") from another script.
I have a section named section-name in file page.php. I guess page.php has a problem figuring out the value of the id to process (3 or 3#section-name). I am redirected to page.php which has its content repeated vertically.
You've only presented half of your code so I can only give a sample of the proper way to do it:
<body>
<a name="top"> </a>
<a href="#top">
Go To Top Of Page
</a>
</body>
When using anchor tags, you can target an element by its ID. Browsers will look for the ID before it looks for the name attribute when the link refers to such.
<a href="#section-name>LINK</a> will go directly to <div id="section-name"> if it exists.
Here's an example
Read: HTML Anchors with 'name' or 'id'?
A typical anchor tag works as follows:
A href link tag is written like so:
Jump to a001
See the #a001 above? That is referencing an id in the HTML page, and it will jump to it if you click this link.
To provide an example of how this id that we would jump to might look on a page, look below.
<li id="a001">text here</li>
Reference

Grails g:render a template (or render a div) onClick event

I am creating a hierarchical list with expandable/ collapsible list items. When a user clicks on a list item to expand it a table pops up with some info. Right now, grails is rendering all of the tables when the page is loaded. However, I only want the tables to be loaded when the list item is clicked. I am using partial templates to house the table html and using
<g:render>
To render them. Is there a way to convert the code I am going to post so that the div with class="list" to only load on click? If not, is there a way to call the g:render tag only on click?
<g:each in="${group2List}" var="item">
<li class="liClosed"><b>
${item}
</b> <%= Application.findAllWhere((group2): item, (group1): group).size() %>
<ul>
<div class="list">
<table id="portfolio">
<g:render template="tableHeader" />
<g:render template="applicationRow"
collection="${Application.findAllWhere((group2): item, (group1): group)}"
var="applicationInstance" />
</table>
</div>
</ul></li>
<br />
</g:each>
So, Is there a way to add an onClick event for the li that renders that div class="list" only on click? Or a way to call those g:renders onClick while keeping them inside the ul.
Thanks for any help!
Like #sudhir commented above, you can't load server-side content into client-side content. The grails tags are rendered once the page is loaded. But you can use ajax to load the data in the server and render a partial template with the new data in it. That's exactly what you need. You can check out this link that may fit your needs.

HTML div navigation

I`ve seen on various websites, some links appear like this: http://www.myserver.com/page.html#something and when I click on it, it just moves to another portion of the page.
I want to know how to do this. Is it only the URL of the <a href> atrribute?
The fragment at the end of the url coresponds to an ID on the page you're visiting.
If in my page I have a section such as:
<div id="comments">
...
</div>
Then I can take the user to this section by attaching #comments to the pages URL
(http://www.example.com/page.html#comments)
Link to comments
Update
Some of the other answers here correctly point out that you can create an anchor with a name attribute as: <a name="example"></a>.
Although this is technically correct, it's also a very antiquated way of doing things and something I'd recommend you avoid. It's very 1997 as some might say :-)
The text after the hashtag corresponts with an anchor on the page. An anchor is a hidden element on the page which you can link to.
Think for example about a large page with an to top link in it
To create an anchor use:
<a name="C4"></a>
To link to it use: Text
Or you can even link to an id of an element
Check out: links (aka anchors)
Also note that you can use <a name="something"></a> or <a id="something"></a>
or using divs <div id="something"></div>
This is a link to a bookmark on the given page (or even just #something on the current page).
To make it work, you need to define something. You can do this using the name attribute of an <a> tag.
http://programming.top54u.com/post/HTML-Anchor-Bookmark-Tag-Links.aspx