0

Sorry if my title is a little confusing. Here is my dilemma...

I have a product category page with different products. I'm trying to figure out a way to say {if segment_3} show the product specific information. Right now I'm having no luck. I'm new to EE, so I'm sure some of you vets this will be easy. Here is my code so far.

<section>
<div class="container">
    <div class="row">
    {exp:channel:entries channel="products" category="1" limit="15"}
        <div class="col-md-4">
            <div class="product-wrapper">
                <div class="product-card">
                    <a href="{segment_2}/{url_title}" class="product-img-wrapper"><img src="{card_img}" alt=""></a>
                    <h4>{title}</h4>
                    {short_description}
                    <div class="btn-container">
                        <a href="{segment_2}/{url_title}" class="btn btn-lg btn-primary">View Product</a>
                    </div>
                </div>
            </div>
        </div>
    {/exp:channel:entries}
    </div> <!-- End Row -->
</div> <!-- End Container -->
</section>

{if segment_3}
{embed="products/product-detail"}
{/if}
1
1

Your syntax is accurate; products/product-detail should be embedded if segment_3 has a value. Perhaps you need to pass data into the embedded template?

Something like:

{embed="products/product-detail" product_id="{segment_3}"}

Then in products/product-detail you would reference the passed data like this:

{exp:channel:entries channel="products" entry_id="{embed:product_id}"}

That might be what you are looking for, but without seeing the contents of products/product-detail there is no way to be sure.

Hope that helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.