X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Is it possible to have your own tabs (https://forum.x-cart.com/showthread.php?t=63596)

Pyro 09-23-2012 06:43 PM

Re: Is it possible to have your own tabs
 
Addison,


Thank you for the base example. Could you please clarify for me?

Quote:

Originally Posted by ADDISON
Files to start digging the code:

[XC_Dir]/include/product_tabs.php (for creating/arranging actual/new tabs)
[XC_dir]/skin/common_files/customer/tabs.tpl (for 2 columns and ideal_comfort skin there are other files)

In product_tabs.php you can insert a new tab like this:

Code:

$product_tabs[] = array(
        'title'  => 'Videos',
        'tpl'    => 'customer/main/tab_videos.tpl',
        'anchor' => 'videos'










I am trying to make a basic tab at the end of my current tabs. This is what is at the end of my current file.


Code:

if (
    !empty($active_modules['Customer_Reviews'])
    && (
        $config['Customer_Reviews']['customer_reviews'] == 'Y'
        || $config['Customer_Reviews']['customer_voting'] == 'Y'
    )
) {
    $product_tabs[] = array(
        'title'  => func_get_langvar_by_name('lbl_customers_feedback'),
        'tpl'    => 'modules/Customer_Reviews/vote_reviews.tpl',
        'anchor' => 'feedback'
    );
}

if (
    !empty($active_modules['Advanced_Customer_Reviews'])
) {
    func_acr_add_product_tab($product_tabs);
}


if (!empty($product_tabs)) {
    $smarty->assign('product_tabs', $product_tabs);
    if ($config['Appearance']['display_product_tabs'] == 'Y') {
        $smarty->assign('show_as_tabs', true);
    }
}
?>







Using your example, I end up with:


Code:

if (
    !empty($active_modules['Customer_Reviews'])
    && (
        $config['Customer_Reviews']['customer_reviews'] == 'Y'
        || $config['Customer_Reviews']['customer_voting'] == 'Y'
    )
) {
    $product_tabs[] = array(
        'title'  => func_get_langvar_by_name('lbl_customers_feedback'),
        'tpl'    => 'modules/Customer_Reviews/vote_reviews.tpl',
        'anchor' => 'feedback'
    );
}

if (
    !empty($active_modules['Advanced_Customer_Reviews'])
) {
    func_acr_add_product_tab($product_tabs);
}


if (!empty($product_tabs)) {
    $smarty->assign('product_tabs', $product_tabs);
    if ($config['Appearance']['display_product_tabs'] == 'Y') {
        $smarty->assign('show_as_tabs', true);
    }
}

$product_tabs[] = array(
        'title'  => 'Videos',
        'tpl'    => 'customer/main/tab_videos.tpl',
        'anchor' => 'videos'
);
?>





Does that look right? I have run cleanup.php, but the tab does not seem to show. My tab_videos.tpl is empty, but I was thinking that the tab should at least show. To test, I also used vote_reviews.tpl to at least populate the tab, but it did not seem to work either.



Any guidance you could give would be greatly appreciated.


Thanks!

ADDISON 09-24-2012 12:27 AM

Re: Is it possible to have your own tabs
 
You have to insert that code before if (!empty($product_tabs)) statement. Because $product_tabs is passed already to the template and you come to add to this array a new value, this is not correct.

Make sure this template file exists customer/main/tab_videos.tpl and having some content (just for testing).

Pyro 09-24-2012 08:54 AM

Re: Is it possible to have your own tabs
 
Addison,

Thank you for the reply. Could you please clarify. Do I need a new

Code:

if (!empty($product_tabs))
line or do I use the last one in the page?


Code:

if (
    !empty($active_modules['Customer_Reviews'])
    && (
        $config['Customer_Reviews']['customer_reviews'] == 'Y'
        || $config['Customer_Reviews']['customer_voting'] == 'Y'
    )
) {
    $product_tabs[] = array(
        'title'  => func_get_langvar_by_name('lbl_customers_feedback'),
        'tpl'    => 'modules/Customer_Reviews/vote_reviews.tpl',
        'anchor' => 'feedback'
    );
}

if (
    !empty($active_modules['Advanced_Customer_Reviews'])
) {
    func_acr_add_product_tab($product_tabs);
}

$product_tabs[] = array(
        'title'  => 'Videos',
        'tpl'    => 'customer/main/tab_videos.tpl',
        'anchor' => 'videos'
);

if (!empty($product_tabs)) {
    $smarty->assign('product_tabs', $product_tabs);
    if ($config['Appearance']['display_product_tabs'] == 'Y') {
        $smarty->assign('show_as_tabs', true);
    }
}
?>



Thanks!

Toora Designs 09-24-2012 09:27 AM

Re: Is it possible to have your own tabs
 
Just tested and it shows video tab
PHP Code:

if (!empty($product_tabs)) {
        
$product_tabs[] = array(
        
'title'  => 'Videos',
        
'tpl'    => 'customer/main/tab_videos.tpl',
        
'anchor' => 'videos'
        
);
}

if (!empty(
$product_tabs)) {
    
$smarty->assign('product_tabs'$product_tabs);
    if (
$config['Appearance']['display_product_tabs'] == 'Y') {
        
$smarty->assign('show_as_tabs'true);
    }



http://i45.tinypic.com/dc68nn.png

ADDISON 09-24-2012 10:48 AM

Re: Is it possible to have your own tabs
 
@Pyro - look how simple it is based on Toora Designs's example.

You can create as much tabs as you want using this code

PHP Code:

$product_tabs[] = array(
        
'title'  => 'tab_name_you_see_in_frontend'// you can define a language label for this
        
'tpl'    => 'skin_path/template_for_this_tab.tpl',
        
'anchor' => 'tab_anchor_name'
); 


You can re-arrange the tabs moving the code up and down with cut&paste. All tabs must be created before this code

PHP Code:

if (!empty($product_tabs)) {
    
$smarty->assign('product_tabs'$product_tabs);
    if (
$config['Appearance']['display_product_tabs'] == 'Y') {
        
$smarty->assign('show_as_tabs'true);
    }



Pyro, do it yourself to see how easy it is. For sure in 2 months you will come here with a brand new solution for creating and re-arranging tabs in admin (content, position), with enable/disable, of course new/remove tabs should use jQuery :)

Pyro 09-24-2012 04:16 PM

Re: Is it possible to have your own tabs
 
Addison and Toora,


Thank you both for your replies. If I could click "thank you" 1,000 times each I would do it! Unfortunately, it only allows me to do it once... so you will have to settle for that. :wink:





As far as copy and pasting goes, I had no problem there. What I was really missing was the understanding of what that last piece of code did. I was under the impression that it was just the last tab - not that it was what "completed" the tabs so to speak.





With that knowledge and Toora's complete example of a complete tab (the if portion is what I was really missing), I was able to successfully make my own tabs.


Thank you both again!

Pyro 09-27-2012 08:50 PM

Re: Is it possible to have your own tabs
 
Toora or Addison,


Could you please clarify something?

If I wanted a certain tab to only show on products from a certain category, would I create an if statement around the existing tab or would I modify the code of the existing tab?



I have tried this, but it does not seem to work as expected.

Quote:

if ($product.categoryid eq "1") {
$product_tabs[] = array(
'title' => 'Sizing Chart',
'tpl' => 'customer/main/sizing_chart_tab.tpl',
'anchor' => 'sizechartt'
);
}



Thank you!

ADDISON 09-27-2012 09:25 PM

Re: Is it possible to have your own tabs
 
check if that variable is available in product page $product.categoryid with debugging console.

Pyro 09-27-2012 09:39 PM

Re: Is it possible to have your own tabs
 
Quote:

Originally Posted by ADDISON
check if that variable is available in product page $product.categoryid with debugging console.



Addison,


Thank you for the reply. I have not used the debugging console before, but I will give it a try now.


Prior, I was using print_r to find what is available, but I could not seem to make it work with the tabs.


Do you happen to have any more specific pointers of where I am going wrong? (Possibly an example?)

Thanks again.

ADDISON 09-28-2012 01:08 AM

Re: Is it possible to have your own tabs
 
Once you find $product.categoryid see it what value has in debugging console. It could not be 1 as you made that if statement.

Hope to write soon a thread about using one of XCart functions named x_log_add. This is a fantastic feature to use it inside a php code and then see what is happening in a separate file. Same like a debugging tool.


All times are GMT -8. The time now is 11:47 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.