Jump to content

MarkupSimpleNavigation


Soma

Recommended Posts

Hello,

I would appreciate if someone could help solving the problem I have. I tried to find some code examples that might solve my issue, but have not been succesfull so far.

The HTML I need to render is the following below. I manage to get all done, except I have no clue how I can have a different class ("other_class") for the "a" tag in the 2nd level of the menu.

Any help is welcome.

thanks

<ul class="navbar-nav">
      <li class="nav-item"><a class="nav-link" href="#">Menu A</a> </li>
      <li class="nav-item dropdown"><a class="nav-link dropdown-toggle" href="#">Menu B</a>
            <ul class="dropdown-menu">
                 <li class="nav-item"><a class="other_class" href="#">Subitem of Menu B</a></li>
              </ul>
      </li>
  </ul>
Link to comment
Share on other sites

  • 3 weeks later...
On 2/17/2022 at 2:22 PM, maetmar said:

Hello,

Hello @maetmar. Welcome to the forums. 

On 2/17/2022 at 2:22 PM, maetmar said:

I tried to find some code examples that might solve my issue, but have not been succesfull so far.

The HTML I need to render is the following below. I manage to get all done, except I have no clue how I can have a different class ("other_class") for the "a" tag in the 2nd level of the menu.

I have no response to you. I just wanted to point out that I don't think this module is still officially supported. I am not saying it doesn't work; it does. It just won't receive attention from the author, most likely. If you still cannot find an answer to your issue, you might want to consider alternative menu creation modules, such as this -> Menu Builder (I am the author ?). 

Link to comment
Share on other sites

@kongondo, thanks for letting me know. Will check your module next time. In the meantime I solved my problem just doing it manually by extending some of the default navtree templates, without the help of a module.

  • Like 1
Link to comment
Share on other sites

On 2/17/2022 at 3:22 PM, maetmar said:

Hello,

I would appreciate if someone could help solving the problem I have. I tried to find some code examples that might solve my issue, but have not been succesfull so far.

The HTML I need to render is the following below. I manage to get all done, except I have no clue how I can have a different class ("other_class") for the "a" tag in the 2nd level of the menu.

Any help is welcome.

thanks

<ul class="navbar-nav">
      <li class="nav-item"><a class="nav-link" href="#">Menu A</a> </li>
      <li class="nav-item dropdown"><a class="nav-link dropdown-toggle" href="#">Menu B</a>
            <ul class="dropdown-menu">
                 <li class="nav-item"><a class="other_class" href="#">Subitem of Menu B</a></li>
              </ul>
      </li>
  </ul>

I do stuff like this using hooks, have a look it may be useful to you in many cases

$nav = $modules->get("MarkupSimpleNavigation"); // load the module    

i added this hook after menu options

$nav->addHookAfter("getTagsString", null, 

function($event){
    $item = $event->arguments('page');

    // first level items need additional attr
    if($item->numChildren(true) && count($item->parents) < 2 && $item->id != 1){
        $title = $item->get("title|name");
        $event->return = '<a href="#" class="dropdown-item dropdown-toggle">' . $title . '</a>';
    }

    // submenus don't need class and data attribs
    if( //$item->numChildren(true) &&
		count($item->parents) > 1){
        $event->return = '<a href="' . $item->url . '">' . $item->get("title|name") . '</a>';
   }
}

);

It may be useful to you

Link to comment
Share on other sites

  • 1 month later...

Hi hello,

don't laugh pls, but I upgraded an old site from 2013, PW 2.2.9 to 3.0.184 via 2.7 - which went fine! just awesome.

Unbelievable.

Yet another reason to love processWire.

Only MarkUpSimpleNavigation doesn't show unpublished items. Otherwise works fine!

I have no errors in the logfile.

Only error I get is when trying to edit a field ** or a template ** (any):

Notice: Use of undefined constant JSON_UNESCAPED_UNICODE - assumed 'JSON_UNESCAPED_UNICODE' in \wire\modules\Inputfield\InputfieldTextTags\InputfieldTextTags.module on line 572

Warning: json_encode() expects parameter 2 to be long, string given in \wire\modules\Inputfield\InputfieldTextTags\InputfieldTextTags.module on line 572

but I guess this can't be the reason. (Since I'm a non-coder, I don't know what to do with this.)

 

Edited by wishbone
Link to comment
Share on other sites

thx!

Yes you're right - PHP 5.3.8 (xampp 1.7.7)

Imported site, wire, .htaccess and index.php into another xampp install - 8.1.5 for windows with PHP 8.1.5 which throws these fancy errors:

Quote

Deprecated: substr(): Passing null to parameter #1 ($string) of type string is deprecated in \wire\core\PagesSortfields.php on line 98
Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in \wire\core\Selectors.php on line 1484

the latter repeated many times)

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in \wire\core\WireArray.php on line 587

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in \wire\core\WireArray.php on line 593

Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in \wire\core\WireArray.php on line 598

Part of the frontend can be seen through these errors.

Trying to log in gives these errors:

Quote

Deprecated: Return type of ProcessWire\WireDatabasePDOStatement::bindValue($parameter, $value, $data_type = PDO::PARAM_STR) should either be compatible with PDOStatement::bindValue(string|int $param, mixed $value, int $type = PDO::PARAM_STR): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in \wire\core\WireDatabasePDOStatement.php on line 126

Deprecated: Return type of ProcessWire\WireDatabasePDOStatement::execute($input_parameters = null) should either be compatible with PDOStatement::execute(?array $params = null): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in \wire\core\WireDatabasePDOStatement.php on line 144

Deprecated: Return type of ProcessWire\LanguagesPageFieldValue::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in \wire\modules\LanguageSupport\LanguagesPageFieldValue.php on line 302

plus the above errors

I'm lost.

Where did I go wrong?

Link to comment
Share on other sites

I would go with PHP 8 and the latest dev (soon to become a master). We have ironed out like 99% od deprecation warnings in PHP8, some may still pop up, but will be fixed promptly.
  • Like 1
Link to comment
Share on other sites

wow!

works (as far as I can see at the moment) !

Only error: login failed

Quote

Deprecated: Implicit conversion from float 7.5 to int loses precision in C:\xampp\htdocs\ditib-ma-pw\wire\core\Password.php on line 249

where it says:

			// split the password in two
			$splitPass = str_split($pass, (strlen($pass) / 2) + 1);

 

Link to comment
Share on other sites

works! great! thank you so much for walking me through this.

I changed in config.php
$config->chmodFile = '0666'; to 644 and
$config->chmodDir = '0777'; to 755, is that correct?

When going to debug mode tools, I find this error with the old language tool (which I hoped not to have to change ? ). Works correct though:

Quote

Deprecated: mb_strtolower(): Passing null to parameter #1 ($string) of type string is deprecated in \site\assets\cache\FileCompiler\site\modules\LanguageLocalizedURL.module on line 174

 
when editing a page, I get
Quote

Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in \wire\modules\Fieldtype\FieldtypeRepeater\InputfieldRepeater.module on line 719

Otherwise, everything seems nice!

Link to comment
Share on other sites

I'm not familiar with LanguageLocalizedURL module, but you can change /site/modules/LanguageLocalizedURL.module line 174 to 

$str = mb_strtolower("$str");

In /wire/modules/Fieldtype/FieldtypeRepater/InputfieldRepeater.module replace line 719 with

if(!strlen("$addLabel")) $addLabel = $this->_('Add New');

I reported both of your findings so they will be fixed.

  • Like 1
Link to comment
Share on other sites

don't know if this got to do with the install:

Tried to export the database. Got this notice (Firefox):

Quote

sql.part konnte nicht gespeichert werden, weil die Quelldatei nicht gelesen werden konnte (could not be saved, because the source file could not be read).

I did Firefox troubleshooting refresh.

Now even worse (in Chrome also):

Quote

Breaking news… Error: Exception: SQLSTATE[HY000]: General error: 1194 Table 'pages' is marked as crashed and should be repaired (in \wire\core\WireDatabasePDOStatement.php line 168)

#0 \wire\core\WireDatabasePDOStatement.php(168): PDOStatement->execute(NULL)
#1 \wire\core\WireDatabasePDOStatement.php(148): WireDatabasePDOStatement->executeDebug(NULL)
#2 \wire\core\WireDatabasePDO.php(894): WireDatabasePDOStatement->execute()
#3 \wire\core\PagesLoader.php(1087): WireDatabasePDO->execute(Object(WireDatabasePDOStatement))
#4 \wire\core\Pages.php(214): PagesLoader->getById(Array)
#5 \wire\core\ProcessWire.php(604): Pages->init()
#6 \wire\core\ProcessWire.php(561): ProcessWire->initVar('pages', Object(Pages))
#7 \wire\core\ProcessWire.php(314): ProcessWire->load(Object(Config))
#8 \index.php(52): ProcessWire->__construct(Object(Config))
#9 {main}

This error message was shown because: site is in debug mode. ($config->debug = true; => site/config.php). Error has been logged.

how to do this? The lines don't match.

Link to comment
Share on other sites

  • 1 year later...

Good day everyone,
I'm wondering if this cool module could help me with the following structure, where all »sub-home« pages have the same template:

home (mother page) —> navigation that shows only all child pages from the mother page
- about
- contact
- news

- sub-home A (template subhome) —> navigation that shows only all child pages from A
-- about A
-- contact A
-- news A

- sub-home B (template subhome) —> navigation that shows only all child pages from B
-- about B
-- contact B
-- news B

- sub-home C (template subhome) —> navigation that shows only all child pages from C
-- about C
-- contact C
-- news C

I'm using the markup regions templating. Most child pages use the same templates.

Link to comment
Share on other sites

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
×
×
  • Create New...