Flakx
Flakx

Reputation: 1112

Magento Add url link to open a specific product tab

Magento 1.7.0.0

ok i'm using the product tabs that are available in the modern theme. I've added a custom tab to add reviews as a tab [sucess].

Now where it says:

'Be the first to review this product' i want this link to go to the tab on that page and not go off to the reviews page.

i realise i need to some javascript but it's just i can't work out how to call a tab.

any ideas?

thanks. Andy.

Upvotes: 1

Views: 3450

Answers (2)

Flakx
Flakx

Reputation: 1112

My code looks like this in tabs.phtml:

    <div id="tabs">
<ul>
    <?php foreach ($this->getTabs() as $_index => $_tab): ?>
        <?php if($this->getChildHtml($_tab['alias'])): ?>
            <li class="<?php echo !$_index?' active first':(($_index==count($this->getTabs())-1)?' last':'')?>"><a href="#<?php echo $_tab['alias'] ?>"><?php echo $_tab['title']?></a></li>
        <?php endif; ?>
    <?php endforeach; ?>
</ul>
<div class="clearer"></div>
<?php foreach ($this->getTabs() as $_index => $_tab): ?>
    <?php if($this->getChildHtml($_tab['alias'])): ?>
        <div class="product-tabs-content" id="<?php echo $_tab['alias'] ?>"><?php echo $this->getChildHtml($_tab['alias']) ?></div>
    <?php endif; ?>
<?php endforeach; ?>
</div>

and then adding: jquery-ui-tabs.js and the relevant .css

Upvotes: 0

Kamal
Kamal

Reputation: 1964

if you already using jQuery... you could just simply "hack" it out like this

jQuery(document).ready(function($){
        $("#addreview").attr("href", "#review-form");
        $("#addreview").click(function(){
            $(".product-tabs").children("li").removeClass("active");
            $("#product_tabs_reviews").addClass("active");
            $(".product-tabs-content").css("display", "none");
            $("#product_tabs_reviews_contents").css("display", "block");
        });
    });

be aware to change the selector according to your own markup

Upvotes: 2

Related Questions