I have a site, using EE 1.73, set up with various weblogs and am trying to pass the correct info to the html tag.
I have added the following to the tag -
{if segment_3}
<title>{site_name} | {exp:weblog:entries weblog=“features|reviews|tutorials|catchreports|news|species|rigs|videos” limit=“1” disable=“categories|custom_fields|member_data|pagination|trackbacks”
}{weblog} | {title}{/exp:weblog:entries}</title>
{if:else}
<title>{site_name}</title>
{/if}
And this correctly give the title for the home page as - Planet Sea Fishing Digital Magazine
The actual article title is fine too with http://www.planetseafishing.com/reviews/read/the-reel-service-centre/ being rendered correctly as Planet Sea Fishing Digital Magazine | Reviews | The Reel Service Centre
My problem, as a beginner, is that I can’t figure out how to get the page title for the actual weblog to render correctly ie for http://www.planetseafishing.com/reviews/ to show as Planet Sea Fishing Digital Magazine | Reviews
I presume that it has something to do with using the fact that segment_3 is blank in this case but no matter what I try I can’t get the title to render properly.
Any suggestions?
Thanks
David
Are you using one template to serve the site index, the weblog listing and the weblog entries? If so you could try nested your conditionals like this:
{if segment_3}
<title>{site_name} | {exp:weblog:entries weblog="features|reviews|tutorials|catchreports|news|species|rigs|videos" limit="1" disable="categories|custom_fields|member_data|pagination|trackbacks"
}{weblog} | {title}{/exp:weblog:entries}</title>
{if:else}
{if segment_2}
<title>{site_name} | {exp:weblog:entries weblog="features|reviews|tutorials|catchreports|news|species|rigs|videos" limit="1" disable="categories|custom_fields|member_data|pagination|trackbacks"}{weblog}{/exp:weblog:entries}</title>
{if:else}
<title>{site_name}</title>
{/if}
{/if}
I don't quite understand your structure tho. Based on your url it looks like "reviews" is a template group as well as a weblog. Does each weblog have it's own template group?
I believe that in EE 1.x, the title for the weblog can be accessed via the EE variable {blog_title}, which is different than the {title} variable used to access the entry title.
Try this code, without any conditionals. By the inclusion of the "require entry=yes" parameter, hopefully this code will only show your expanded blog and page titles when the result of your {exp:weblog:entries} call actually returns an entry - i.e., when there's dynamic data to present via the URI. Otherwise, it shouldn't display anything.
Hopefully I'm not missing your intent!
<title>{site_name}{exp:weblog:entries weblog=“features|reviews|tutorials|catchreports|news|species|rigs|videos” limit=“1” disable=“categories|custom_fields|member_data|pagination|trackbacks” require_entry="yes"
} | {blog_title} | {title}{/exp:weblog:entries}</title>
Related
I've got a website with two channels, news and products.
Products are displayed using an embedded channel entries tag pair called marketing. The news articles are displayed using a regular channel entries tag pair.
When the user clicks on a news article, the website navigates to a new page (news/view) containing the contents of just the news article in question. The template also includes the embedded template containing the products tag pair. This is where the problem occurs: the only published item that displays is the news article. None of the products display on the news article template.
The homepage and 'news/view' mock-up:
{exp:channel:entries channel="news"}
{title}
<some markup>
{body}
{/exp:channel:entries}
{embed="includes/marketing"}
The marketing embedded template looks something like:
<some dividing markup>
{exp:channel:entries channel="products"}
<list markup>
{product_image}
{product_description}
</list markup>
{/exp:channel:entries}
</some dividing markup>
Since the homepage and the 'news/view' template are essentially the same, I have no idea why the products are displaying on the homepage and not the 'news/view' page.
I'm not entirely sure but try adding dynamic="no" to your channel:entries loop. This seems to resolve 99% of my EE problems :)
{exp:channel:entries channel="products" dynamic="no"}
I am using the channel:categories tag to pull in categories for a section navigation. This works fine, but I also would like to tag the current active category as the active item in the navigation for styling purposes:
a class="active"
I tried two approaches neither of which works.
Attempt 1 (per the documentation):
<a {if active} class="active"{/if} href="{path='internal-staff-center/{category_url_title}'}">{category_name}</a>
Attempt 2:
<a {if segment_2 == "{category_url_title}"}class="active"{/if} href="{path='internal-staff-center/{category_url_title}'}">{category_name}</a>
I would appreciate some input from another viewpoint out there.
Thanks.
The {path} variable within Channel Categories will output a path using your category trigger word or the C(n) URL segment (C2, C15, etc). So it's doubtful that {segment_2} is actually your category_url_title ... it's more likely {segment_3}.
What is an example URL structure of these pages?
{if segment_X == category_url_title} should work so long as the comparison is correct.
Try
{if "{segment_2}" == "{category_url_title}"} class="current"{/if}
Any way in Expression Engine to simulate Wordpress' shortcode functionality?
I want to abide by community rules, and there's a disclaimer when clicking in the "answer" section of an existing question that says I should actually ANSWER the question, not respond to other answers.
As such, I have the same question as the one above. I am a dev with roots in WordPress and I would like to mimic the behavior of WP shortcodes in Expression Engine. All I want to do is save a snippet of code as a template that can be re-used all across my site.
For example, if I want to use an accordion menu on several pages, I could just click click while editing a page and the code appears with placeholder content that the user/dev can then replace with real content). Do I need a graphic slideshow? Click click, define the images/headings/text overlays.
As I'm posting this, I'm about to scour the EE plug-ins library but since I haven't found anything before, I wanted to post here first.
I cover an approach that I've used before in http://www.tyssendesign.com.au/articles/cms/more-stash-examples/ along with a couple of other examples of using Stash.
Short answer: there is not such a thing ... yet. The Shortcode add-on is currently in beta.
Long answer for now: use custom fields. Example: a Matrix field for your accordion, with your columns defined, and add as many row as you like. Then add tags for that in your template.
Same with a Gallery - create a Gallery field (Matrix works great for this again), then add the code to your template to build the gallery.
If these fields are made optional, then they only appear on the front-end when used.
If you want to get fancy and inject these chunks of content into your main content area, you can use NSM Transplant to do so.
Here's a simplified snippet of code I use on one site to acheive this:
{exp:nsm_transplant:body}
{inline_media}
{exp:nsm_transplant:content id="media_{row_count}"}
<figure class="{alignment}">
{exp:ifelse parse="inward"}
{if image}
{if "{alignment}" == "aligncenter"}
{exp:ce_img:make src="{image:resized}" width="860" quality="80" output='<img src="{made_url}" alt="" />'}
{if:else}
{exp:ce_img:make src="{image:resized}" width="430" quality="80" output='<img src="{made_url}" alt="" />'}
{/if}
{if:elseif video}
{if "{alignment}" == "aligncenter"}
{exp:antenna url="{video}" max_width="860"}
{if:else}
{exp:antenna url="{video}" max_width="430"}
{/if}
{if:elseif gallery}
{gallery}{embed="galleries/_embed" entry_id="{entry_id}"}{/gallery}
{/if}
{if caption}<figcaption>{caption}</figcaption>{/if}
{/exp:ifelse}
</figure>
{/exp:nsm_transplant:content}
{/inline_media}
{content}
{/exp:nsm_transplant:body}
In this case authors use {media_1}, {media_2} etc, to embed photos, videos, and galleries inside the content.
Another solution you can look at is Content Elements, which allows a more freeform method of populating an entry with a single custom field.
Hope that helps!
You can also use global variables within EE templates. You cannot use EE tags inside templates, but global variables do work. So anything that you can save as a global variable (possibly including variables made with the addon Low Variables, but I have not verified that) can be included into an EE template.
So if you need static HTML, or images, or whatever, you can absolutely mimic quite a bit of shortcode functionality by creating global vars and invoking them using the ordinary {global_var_name} syntax inside an entry field. Note that EE tags inside global variables will not get parsed, though, so you cannot use this to do an end run around parsing restrictions!
I'm trying to create a Safecracker form in ExpressionEngine to create a recipe. I have a recipe channel, which can have many ingredients from an ingredients channel (using the multi-relationship add-on from devot:ee). However, I'm having trouble listing the ingredients within my form. This is my mark-up:
{exp:safecracker channel='recipes' datepicker='no' id='add-recipe-form' include_jquery='no' return='recipes/view/ENTRY_ID' safecracker_head='no'}
{related_entries id='ingredients'}
{title}
{/related_entries}
{/exp:safecracker}
The problem is, the actual EE tags are just getting output on my web page.
I figure I'm doing something fundamentally wrong, so could someone point me in the right direction? Thanks.
This is called "variable collision" - you're nesting entries which use the same variable/tag names as those used by the parent tag (in this case, {title}), and due to how EE's parse order works, the parent tag is winning every time.
The solution is to put your above code into another template, and embed that template within your Safecracker form. Embeds are run at the very end of template processing, after all of the other EE tags are parsed, so you won't run into the same collision.
Derek is right, you need to embed your related entries. I've got this working on my Toronto EE meetup site with this code.
Simplified Template code:
{exp:safecracker channel="gta-attendee"}
<div class="form_row" style="display:none;">
<label class="small">Choose Meetup to Attend:<span class="required">*</span></label>
{embed="includes/_playa_select" selected="{attendee-event:child_ids}" }
</div>
{/exp:safecracker}
embedded code:
{exp:channel:entries dynamic="no" channel="gta-meetup" limit="1"}
<input value="{entry_id}" name="attendee-event[selections][]" type="hidden">
{/exp:channel:entries}
In the code I'm using the Playa Module, but the principle is the same.
Hope this helps
Sean
I am working on an EE 1.7.1 site and need to display the two most recent article entries on the home page. The challenge is that I also need to link those entries back to their respective category pages to display properly.
Here is the code I have so far:
{exp:weblog:entries weblog="articles" limit="2"}
<p>{title}</p>
{/exp:weblog:entries}
Here is what I would like to do so that it brings in the corresponding :
{exp:weblog:entries weblog="articles" limit="2"}
{categories}
<p>{title}</p>
{/categories}
{/exp:weblog:entries}
Unfortunately this doesn't work correctly. What is the right way to do this?
Thanks.
ExpressionEngine doesn't natively have a method of including the Category Name as a URL Segment when outputting the Permalink URI, unlike, say, WordPress.
It can be done of course, but will require hacking around the standard EE URL Segments.
If you're even the least bit curious, this was discussed in more detail on the EE Podcast, Episide #10 Behind the Scenes at Playgrounder.
The relevant discussion between Dan Benjamin and Ryan Ireland occurs between 18:45 - 26:20, when Dan details how he developed the unique permalink structure for Playgrounder:
Spoiler Alert: Playgrounder URLs are built using a last segment variable to
lookup the Entry URL Title, while the rest of the preceding URL is the output by
looping thru the entry's categories.
For example, given the following URL:
http://playgrounder.com/stuff/learning/books/sneaky-uses-for-everyday-things
Would translate into EE parlance as:
/index.php/category_url_title/.../url_title
You probably need to add dynamic="off" parameter in exp:weblog:entries tag.
Are you trying to show the latest two entries and their associated categories? Such as:
Entry Title
Posted In: Gifts, Pets, Toys
Some Other Entry Title
Posted In: Toys, Toddlers
If that's what you're trying to do, the following code will output the above:
{exp:weblog:entries weblog="news" limit="2"}
<p>
{title}<br />
{categories limit="1"}
{if category_id != ""}Posted In: {/if}
{/categories}
{categories backspace="2"}{category_name}, {/categories}
</p>
{/exp:weblog:entries}