开发者

smarty: {if div with class="one" is enabled, (HTML snippet1) Else (HTML snippet")

on the site I'm开发者_如何学Python working on, I need to show two different HTML snippets depending if another element is activated or not.

Like:

{if "div class="box expandResults" is enabled(or appearing on the page)"}

....HTML....

{else}

....OTHER HTML....

{/if}

How can I do this with Smarty or jQuery? I only have access to the .tpl files.

Thanks :)


Do it with JavaScript. Generate following HTML:

<div id="boxExpandResultsEnabled" style="visibility: hidden"> 
....HTML...
</div>
<div id="boxExpandResultDisabled" style="visibility: hidden"> 
....OTHER HTML....
</div>

JavaScript for Prototype would be:

<script>
        if($$('div.box expandResult')) {
            $('boxExpandResultsEnabled').show();
        } else {
            $('boxExpandResultsDisabled').show();
        };
</script>

Same thing for JQuery:

<script>
        if($('div.box.expandResult')) {
            $('#boxExpandResultsEnabled').show();
        } else {
            $('#boxExpandResultsDisabled').show();
        };
</script>


Well, you surely have some condition to make div class="box expandResults" appear on the page, so why not use the same one for this other case?

I the div in question is showed/updated via javascript (AJAX or something similar), then you can't do this with smarty alone.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜