Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: etc_tree: trees for geeky grandmas
Glad you have solved it. It’s a temporary solution, I should think of packing the whole tree in one _POST variable, but have no time atm.
Offline
#17 2016-05-26 06:47:44
- bashirnoori
- Member

- From: Afghanistan
- Registered: 2012-10-02
- Posts: 86
Re: etc_tree: trees for geeky grandmas
how to assign dynamic class for each list which has submenus, example:
<li><a href="...">Home</a></li>
<li class="hasmenu"><a href="...">News</a>
<ul class="submenu">
<li><a href="...">Local</a></li>
<li class="hasmenu2"><a href="...">Global</a>
<ul class="submenu2">
<li><a href="...">Sports</a></li>
<li><a href="...">Plitics</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="...">Contact</a></li>
Offline
Re: etc_tree: trees for geeky grandmas
Not sure it’s a good idea to use numbers in class names, but you can:
<txp:etc_query
data='<txp:etc_tree id="0" />'
replace="//ul@@class=submenu{##};//li[ul]@@class=hasmenu{##}"
/>
Edit: or this, if you want to assign numbers by levels:
<txp:etc_query
data='<txp:etc_tree id="0" />'
replace="//ul@@class=submenu{count(ancestor::ul)};//li[ul]@@class=hasmenu{count(ancestor::ul)}"
/>
Last edited by etc (2016-05-26 08:54:38)
Offline
#19 2016-05-27 13:10:35
- bashirnoori
- Member

- From: Afghanistan
- Registered: 2012-10-02
- Posts: 86
Re: etc_tree: trees for geeky grandmas
<txp:etc_query
data='<txp:etc_tree id="1" />'
replace='//a[@href="<txp:etc_url />"]@@class=active'
/>
Assigning active class to the current menu works fine,
but if we have nested menus that will assign just to that nested menu, not assign to the top level menu.
e.g. I need like this: if i’m in the Local page active class should assign for Local & News menus.
<li><a href="...">Home</a></li>
<li><a href="...">About</a>
<li><a class="active" href="...">News</a>
<ul class="submenu">
<li><a class="active" href="...">Local</a></li>
<li><a href="...">Global</a></li>
</ul>
</li>
<li><a href="...">Contact</a></li>
Reason: if don’t assign active class to the top level menus, nested menus are hidden by default and no one know I’m in which page !
Offline
Re: etc_tree: trees for geeky grandmas
Does this help?
<txp:etc_query
data='<txp:etc_tree id="1" />'
replace='//a[@href="<txp:etc_url />"]@@class=active;
//a[@href="<txp:etc_url />"]/ancestor::ul/preceding-sibling::a[1]@@class=active'
/>
This assumes you always have <a /> link before <ul />.
Offline
#21 2016-06-06 10:41:31
- raminrahimi
- Member

- From: India
- Registered: 2013-03-19
- Posts: 278
Re: etc_tree: trees for geeky grandmas
i think there is a bug: when you create new List menu, you can’t drag/drop any submenus to inner of that until reloading the page or clicking save button.
Note: i’m using firefox 46.
Offline
#22 2016-06-19 06:53:27
- raminrahimi
- Member

- From: India
- Registered: 2013-03-19
- Posts: 278
Re: etc_tree: trees for geeky grandmas
how i can assign a class and ID to first-child of <ul> that’s my main menu wrapper ?
my code is now:
<txp:etc_query
data='<txp:etc_tree wraptag="ul" break="li" id="12" />'
replace='//a[@href="<txp:etc_url />"]@@class=active'
/>
Offline
Re: etc_tree: trees for geeky grandmas
Looking at the plugin help, it looks like the etc_tree tag has support for class="my-wrapper-class" and breakclass="item-class" attributes.
TXP Builders – finely-crafted code, design and txp
Offline
#24 2016-07-05 06:02:08
- raminrahimi
- Member

- From: India
- Registered: 2013-03-19
- Posts: 278
Re: etc_tree: trees for geeky grandmas
Everything was fine, but today I’m going to add some new menus to etc_tree
after clicking save button, etc_tree menus goes hide and no changes apply
when i checked the Console -> Network , this error appear: I’m sorry. I’m afraid I can’t do that; etc_tree save is an unsafe operation.
Note: adding new menu not works, but if i remove any menu it will save fine !
Offline
Re: etc_tree: trees for geeky grandmas
Isn’t it the same post size problem? Can you still modify an existing node?
Offline
#26 2016-07-11 08:44:07
- raminrahimi
- Member

- From: India
- Registered: 2013-03-19
- Posts: 278
Re: etc_tree: trees for geeky grandmas
No that’s not the issue of post size problem, because i changed everything to high size, here is the response when i checked the network console:
<script type="text/javascript">
window.alert("Internal error \"Field \'lft\' doesn\'t have a default value\".\n")
</script>
I’m sorry. I’m afraid I can’t do that; <code>etc_tree</code> <code>save</code> is an unsafe operation
.
Offline
Re: etc_tree: trees for geeky grandmas
Thanks for the report, sorry for the trouble. If it worked before, I guess your db settings have been changed recently (strict mode, maybe). Try to edit `etc_tree` table structure, setting default values of `lft` and `rgt` columns to 0. If it works, I will update the plugin.
Offline
#28 2016-07-11 10:42:40
- raminrahimi
- Member

- From: India
- Registered: 2013-03-19
- Posts: 278
Re: etc_tree: trees for geeky grandmas
i uninstalled etc_tree plugin and reinstalled again, but didn’t solve the problem, then i changed the field structure lft and rgt Default from None to NULL then it works fine.
Offline
#29 2016-07-28 06:29:23
- raminrahimi
- Member

- From: India
- Registered: 2013-03-19
- Posts: 278
Re: etc_tree: trees for geeky grandmas
right now active class apply just for URLs that ends with ‘/’ (slash) e.g http://localhost/category/news/
but it will not apply active class to the URLs without ending ‘/’ (slash) e.g http://localhost/?c=news
i use the following code:
<txp:etc_query
data='<txp:etc_tree id="1" />'
replace='//a[@href="<txp:etc_url />"]@@class=active'
/>
Offline
Re: etc_tree: trees for geeky grandmas
You can try the following:
<txp:etc_query
data='<txp:etc_tree id="1" breakclass=",activeli" />'
replace='//li[@class="activeli"]/a@@class=active'
/>
Offline