ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Embed tag limit?

November 12, 2010 12:29pm

Subscribe [2]
  • #1 / Nov 12, 2010 12:29pm

    Hello,

    Is there away of limiting or offsetting weblog entries via an embed tag?
    I have a some code within an embed tag that I want to use around my site and wanted to limit number of entries so I don’t need to duplicate my embed tag around my site.

    So something like

    {embed="template/news" loc="index" limit="10"}
    for the index page and
    {embed="template/news" loc="morenews" limit="10" offset="10"}

    for when people are on the news page?

    Thanks in advance for anyone able to help!
    Tony

  • #2 / Nov 13, 2010 2:10pm

    Greg Salt

    3988 posts

    Hi Tony,

    I’m afraid that I’m not really sure what it is that you are asking. The examples that you’ve posted would be what you need to do if you need to set different parameters for an embed. Can you clarify your problem?

    Cheers

    Greg

  • #3 / Nov 13, 2010 3:36pm

    Hi Greg,

    First of all sorry for not being clear about my problem, my head was all over the place yesterday so I hope this helps…

    I have an template group called “inc” here all my includes for my site go. I have an include file called “news_entry” and the code is the following:

    {exp:weblog:entries weblog="news" orderby="date" limit="10"}
    {newstitle}
    {newsurl}
    {newscontent}
    {/exp:weblog:entries}

    Now on my index page I call this include like so: {embed="inc/news_entry" loc="index"}
    and that works just fine. I also have a news page (just called news) where I archive the news I post, so the front page only shows 10 of the latest news stories and if people go to /news they see an archive of my old posts.

    Now the issue I have is I need to offset the news stories when people are on the /news page as I don’t want them to see the same stories again as they just have from the front page. So this is what I had to do in order to get it to work the way I wanted:

    news_entry

    {if "{embed:loc}" == "index"}
    {exp:weblog:entries weblog="news" orderby="date" limit="10"}
    {newstitle}
    {newsurl}
    {newscontent}
    {/exp:weblog:entries}
    {/if}
    
    {if "{embed:loc}" == "news"}
    {exp:weblog:entries weblog="news" orderby="date" limit="10" offset="10"}
    {newstitle}
    {newsurl}
    {newscontent}
    {/exp:weblog:entries}
    {/if}

    As you can see I had to repeat the weblog entry tags again just to use the offset feature. Now if I need to make some changes in the future to my entry design I would have to do it twice.

    So I was wondering if there was a better way of doing this? I am sorry for the mental question but I am still new to EE and am still playing around with it.

    Please let me know if I made more sense….

    Thanks again for the rapid help!
    Best regards,
    Tony

  • #4 / Nov 14, 2010 3:04pm

    Greg Salt

    3988 posts

    Hi Tony,

    What you have done is the best way to deal with this. Although there a multitude of options to the exact way that you do this the overall method you have is correct.

    Cheers

    Greg

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases