Embedding in sub-tabs


If you would like to embed sub-tabs in tabs, you can easily do that too with Name.ly Custom API. The only fact you have to bear in mind is that each API parameter is limited to 512 characters, so if you end up having too long URLs you should shorten them.

Below goes an example of how two show categories in tabs and products in sub-tabs:

  1. // Data structure
  2. $categories = array ();
  3. $categories [] = array (
  4. “name” => “Books”,
  5. “products” => array (
  6. array ( “url” => “http://www.ozon.ru/context/detail/id/5561766/”,
  7. “name” => “Books 1” ),
  8. array ( “url” => “http://www.ozon.ru/context/detail/id/5813135/”,
  9. “name” => “Books 2” ),
  10. array ( “url” => “http://www.ozon.ru/context/detail/id/5505592/”,
  11. “name” => “Books 3” ),
  12. array ( “url” => “http://www.ozon.ru/context/detail/id/5801663/”,
  13. “name” => “Book 4” ),
  14. ),
  15. );
  16. // …
  17. $categories [] = array (
  18. “name” => “Electronics”,
  19. “products” => array (
  20. array ( “url” => “http://www.ozon.ru/context/detail/id/5592866/”,
  21. “name” => “Mobile” ),
  22. array ( “url” => “http://www.ozon.ru/context/detail/id/5862823/”,
  23. “name” => “Phone” ),
  24. array ( “url” => “http://www.ozon.ru/context/detail/id/5623463/”,
  25. “name” => “Laptop” ),
  26. array ( “url” => “http://www.ozon.ru/context/detail/id/5819885/”,
  27. “name” => “HDD” ),
  28. ),
  29. );
  30. // PHP Code
  31. $top_parameters = ;
  32. $i = 1;
  33. foreach ( $categories as $key => $category ) {
  34. $parameters = ;
  35. $j = 1;
  36. foreach ( $category[“products”] as $product ) {
  37. if ( $url = trim ( $product[“url”] ) ) {
  38. $parameters .= ‘&url’ . $j . ‘=’ . urlencode ( $url ) .
  39. ‘&caption’ . $j . ‘=’ . urlencode ( $product[“name”] );
  40. $j++;
  41. }
  42. }
  43. if ( $parameters ) {
  44. $categories [$key] [“bundled_link”] = ‘http://many.at/links2tabs/?toc=off&title=My+Shop&description=’ .
  45. urlencode ( $category[“name”] ) . $parameters;
  46. $categories [$key] [“bundled_shortlink”] = bit_ly_shorten ( $categories [$key] [“bundled_link”] );
  47. $top_parameters .= ‘&url’ . $i . ‘=’ . urlencode ( $categories [$key] [“bundled_shortlink”] ) .
  48. ‘&caption’ . $i . ‘=’ . urlencode ( $categories [$key] [“name”] );
  49. $i++;
  50. }
  51. }
  52. if ( $top_parameters ) {
  53. $bundled_link = ‘http://links2.me/links2tabs/?toc=’ . urlencode ( ‘ToC’ ) . $top_parameters;
  54. echo ‘<a href=”‘ . $bundled_link . ‘” target=”_blank”>’ . ‘Open all categories and products with one click’ . ‘</a>’;
  55. }

Open all references in tabs: [1 – 4]


Short link: [Facebook] [Twitter] [Email] Copy - http://name.ly/~Gi9B$D6