Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Linking to articles using the article’s weblog in ExpressionEngine

I have an index template that displays articles from several sections (weblogs), but when linking to an article we must specify the template_group and template to use. I have different template groups for each section, and want to use them as they define the article’s URL. However, the obvious way of using {title_permalink="{weblog_short_name}/index"} doesn’t work (although we can use {segment_#} like this).

You can do this by passing the {weblog_short_name} and {entry_id} of each article to an embedded template using embedded variables:

<!-- the index template that calls the embedded template -->
{exp:weblog:entries weblog="not pages" orderby="date" sort="desc" limit="10" disable="categories|comments|member_data|pagination|trackbacks"}
<div class="article">
{date_heading}<h3 class="date">{entry_date}</h3>{/date_heading}
<h3>{weblog}</h3>
<h2 class="title"><a href="{target_url}" title="{target_title}">{title}</a></h2>
{summary}
<!-- the next line embeds the template and sets the variables -->
<p><a href="{embed="snippet/body-hp-link" the_weblog="{weblog_short_name}" the_entry_id="{entry_id}"}">Read more</a> or comment&hellip;</p>
</div>{/exp:weblog:entries}


<!-- the embedded template -->
{exp:weblog:entries weblog="{embed:the_weblog}" entry_id="{embed:the_entry_id}" dynamic="off" disable="categories|comments|member_data|pagination|trackbacks"}{title_permalink="{embed:the_weblog}/index"}{/exp:weblog:entries}

Link to Remote Tag

Tag for creating ajax callback links

<%= link_to_remote( "click here",
                         :update => "specific_div_block",
                         :url =>{ :action => :action_name }) %>

Link Tag

Basic rails link tag

<%= link_to 'Link Name', { :action => 'action_name', :id => 0 }, :confirm => 'Are you sure?', :post => true %>

pop window desde un link

// esta es una forma muy buena de hacer un pop up desde un link

<a href="http://google.com/" onclick="window.open(this.href, 'popupwindow', 
  'width=400,height=300,scrollbars,resizable'); 
  return false;"
>