Jump to content

Recommended Posts

Posted

I'm trying to figure out how to add tabs to an admin page for my module. 

I tried copying the HTML from a page edit (where there are nice tabs that fit in with the existing UI)

<ul class="WireTabs nav" id="PageEditTabs">
    <li><a href="#drafts" id="_drafts" class="on">Drafts</a></li>
    <li><a href="#history" id="_history">History</a></li>
</ul>

<ul class="Inputfields">
    <li class="Inputfield InputfieldWrapper InputfieldColumnWidthFirst" id="drafts" style="display: block;>
         my first tab (drafts)
    </li>
   <li class="Inputfield InputfieldWrapper InputfieldColumnWidthFirst" id="history" style="display: none;>
        my second tab (history)
    </li>
</ul>
 
 
 
 

....

But they didn't work. Wondering if there is a way to generate admin tabs in processwire for admin pages a module creates?

Posted

You don't add the HTML manually...that is automatically done for you. In a hurry, but have a look at how it is done in various modules, e.g. Batcher and Menu Builder, or in PW pages, e.g. /wire/modules/Process/ProcessPageEdit/ProcessPageEdit.module

The key is to include; $this->modules->get('JqueryWireTabs') in your module, most likely in your init() method and create tabs like shown in Batcher/Menu Builder. You also need to add some short js in your module.js file...Again, see the above modules...Sorry, you will get other answers if this is not clear....

Posted

Thanks Kondogo,

I found a good example in the forum on how to use it: https://processwire....-line-wiretabs/

    $form = $this->modules->get('InputfieldForm');
    $this->modules->get('JqueryWireTabs');

    foreach(array('One', 'Two', 'Three') as $number) {

        $tab = new InputfieldWrapper();
        $tab->attr('id', 'tab_' . $number);
        $tab->attr('title', $number);
        $tab->attr('class', 'WireTab');

        $markup = $this->modules->get('InputfieldMarkup');
        $markup->label = $this->_('Label ') . ' ' . $number;
        $markup->value  = "<h2>$number</h2>";

        $tab->append($markup);
        $form->append($tab);
    }

  echo $form->render();

The only thing is it creates accordions instead of tabs, but when I work out the details of getting tabs ill post the solution. Thx.

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...