[英]Create quicktabs programmatically drupal
I am using Drupal 7 & quicktab . 我正在使用Drupal 7和quicktab。 I am trying to create quicktabs from codes.
我正在尝试从代码创建quicktabs。 Suppose i created the a test url in using hook menu.
假设我在使用挂钩菜单中创建了一个测试网址。
$items['MyModule/test'] = array(
'title' => 'Test Tabs',
'type' => MENU_CALLBACK,
'page callback' => 'test',
'page arguments' => array(2),
'access arguments' => array('access content')
);
In test function , 在测试功能中,
function test(){
$name = "Test tabs";
$settings = array(
'ajax' => 0 ,
'hide_if_empty' => 1,
'default_tab' => 0,
'title' => 'Test quicktabs',
'rendered' => 'quicktabs',
'style' => 'Basic',
);
$custom_tabs = array(
array(
'title' => 'Test tab1',
'path' => 'test-tab1',
'contents' => "Test tab1",
'weight' => 0
),
array(
'title' => 'Test tab2',
'path' => 'test-tab2',
'contents' => "Test tab2",
'weight' => 0
));
return drupal_render(quicktabs_build_quicktabs($name, $settings, $custom_tabs));
}
By using above code , i am successfully able to create quicktabs, But It is showing same (Test tab 1) content on both tabs. 通过使用上面的代码,我可以成功创建quicktabs,但是在两个选项卡上都显示相同的内容(“测试”选项卡1)。 Content is not changing.
内容没有改变。 I cleared the cache also.
我也清除了缓存。 Also, How to edit the path of tabs??
另外,如何编辑选项卡的路径? Above path is not working .
以上路径无效。 It is showing ugly path like this
(http:[baseUrl]/test?qt-my_custom_quicktab=3&qt-Test%20tabs=0#qt-Test%20tabs)
它显示了这样的难看路径
(http:[baseUrl]/test?qt-my_custom_quicktab=3&qt-Test%20tabs=0#qt-Test%20tabs)
Is there any better way to implement quicktabs.May be with hooks but documentation is insufficient. 有没有更好的方法来实现quicktabs。可能带有钩子,但文档不足。 If anyone knows better implementation guide me .
如果有人知道更好的实施指导我。 My tabs will be dynamic.
我的标签将是动态的。
If your problem is just the ugly query string ?qt-my_custom_quicktab=...
, you can prevent that using javascript by disabling the default click action for the links that toggle tab-panels. 如果您的问题只是丑陋的查询字符串
?qt-my_custom_quicktab=...
,则可以通过禁用切换选项卡面板的链接的默认单击动作来防止使用javascript。
Example: 例:
jQuery(function() {
jQuery('#your-quicktab-link-selector').click(function(evn) {
evn.preventDefault();
});
});
This is a very old question, but I figured I'd answer for anyone else who stumbled upon the same issue (as I did). 这是一个非常老的问题,但我想我会为偶然发现同一问题的其他人(像我一样)回答。
The problem is that your variable $name (or the first parameter to quicktabs_build_quicktabs()) should not have spaces. 问题在于您的变量$ name(或quicktabs_build_quicktabs()的第一个参数)不应包含空格。 So, if you do something like the following, it will work.
因此,如果您执行以下操作,那么它将起作用。
$name = "Test-tabs";
The issue is that quicktabs assigns that string as part of the ID of the div wrapper on the tab. 问题是quicktabs将该字符串分配为选项卡上div包装器ID的一部分。 If it has a space in it, then the javascript code won't successfully hide or show the correct tabs.
如果其中有空格,则javascript代码将无法成功隐藏或显示正确的标签。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.