-
Posts
1,366 -
Joined
-
Last visited
-
Days Won
49
Everything posted by flydev
-
Need help to output flag icon in drop down (multi language)
flydev replied to flash's topic in General Support
I just edit my previous post. -
Need help to output flag icon in drop down (multi language)
flydev replied to flash's topic in General Support
If you are using a variables to hold a page, then you should avoid using this same variable name in your loops. eg: foreach($footer->navigation as $subnav) instead of foreach($footer->navigation as $footer) // redefinition Now that you don't override the $footer variable in the loop, you don't even need to re-declare it, you can use it in the whole template file (not the website!). The variable $p was only available in the scope of the loop; Please have read this page: https://www.w3schools.com/php/php_variables.asp and this doc: https://processwire.com/api/variables/pages/ You are calling getLanguageValue() on a null variable ($homepage). To avoid this error, you have three way : define $homepage in the _init.php file : $homepage = $pages->get('/'); // globally available to the website define $homepage at the begining of your template file : $homepage = $pages->get('/'); call getLanguageValue() on $pages->get() : $hreflang = $pages->get('/')->getLanguageValue($language, 'name); Then the magic should happen... after you define some CSS or you will not see a dropdown and flags. There are the CSS attached to the code I give you earlier, you could try to paste it in your CSS file to see what happen and tweak it for your needs : The flags sprite is attached to this post. Some links you should read , everything is fine with basic PHP knowledge, and speaking about that, after some hours, your skills will grow ✌️ https://www.pwtuts.com/processwire-tutorials/appending-a-file-and-initialising-variables/ https://www.pwtuts.com/ https://processwire.com/docs/tutorials/ And please, install this module - https://modules.processwire.com/modules/tracy-debugger/ -so it will be a lot easier to help you, and it will help you to understand PHP and ProcessWire by debugging each vars! be curious ? -
That what I was thinking.
-
Need help to output flag icon in drop down (multi language)
flydev replied to flash's topic in General Support
Avoid using ProcessWire keywords as variable name. You are also redefining $page in your foreach loop. $page is a reserved word, instead, use : <?php $footer = $pages->get("/misc/footer/");?> then : <?php foreach($footer->navigation as $p ): ?> <?php echo $p->myfield; ?> [...] <?php endforeach; ?> then : <?=$footer->heading;?> <?=$footer->phone;?> // etc -
Need help to output flag icon in drop down (multi language)
flydev replied to flash's topic in General Support
Check with the developer tools of your browser, the image should be there. @Gary Austin 's comment is right. Try with this last example, but now its more like a HTML/CSS issue : [...] // output the option tag echo "<option$selected value='$url' style='background-image:url({$language->language_icon->url});'> $language->title </option>"; [...] -
Need help to output flag icon in drop down (multi language)
flydev replied to flash's topic in General Support
I didn't saw that the HTML markup is missing. You need it in order to render the image. Try again with : [...] // output the option tag echo "<option$selected value='$url'> <img src='{$language->language_icon->url}' alt='img description'> $language->title </option>"; [...] -
Yes it could be faster optimizing the query but it could depend on the approach used on your pages tree. In this specific case I think you could do something already solid with the pw api. When you have a moment, you can take a look at this discussion and module (the old thread).
-
Need help to output flag icon in drop down (multi language)
flydev replied to flash's topic in General Support
Sorry for the short answer. I think you are close, try to write $language->language_icon->first()->url or $language->language_icon->url [...] // output the option tag echo "<option$selected value='$url'> {$language->language_icon->first()->url} $language->title </option>"; [...] -
A quick example : $userPassword = $input->post->password; // user input foreach ($pages->get('/')->children as $p) { // iterate all pages $passwordField = $p->password; // get the password field if(!$passwordField || !$passwordField->matches($userPassword)) continue; // not authorized echo "'{$p->title}' Authorized"; } Edit: Nop, you don't need to store the user password, just check it against the password field stored in the page you are looking for. PS: We posted at the same time, let me know if you got it ?
-
Like I said in my previous example, to get the hash : $hash = $pages->get('/passwords/')->password->hash; Install TracyDebugger (or use var_dump() on $hash) and try my code posted earlier. You will see the hash and the salt.
-
So I assume you have a field called "email" in the template "firma" (correct ?). If its not the case, the Find-Page tool will not work as the user template is a system template. Anyway, to have a result here, you have to check your password with the HASH you get and not the plain text password. The tool do not convert the password to a hash on the fly, same as example $pages->find("a selector") will not work with a plain text password; And ProcessWire do not store the plain text password, so trying to compare it here do not make sense. With hash comparison : With plain text password comparison :
-
with the thread I linked above, you can achieve in two lines what you want : $password = 'password1337'; // user input password $hash = $pages->get('/passwords/')->password; // password field from page "passwords" $result = $hash->matches($password); // check if password hash equal to stored password (hash) bd($result); // dump the result with TracyDebugger - return true or false easy as always..
-
Need help to output flag icon in drop down (multi language)
flydev replied to flash's topic in General Support
This is just a frontend example for inspiration (should work as is) - the flag image is set trough CSS (gf-if and gspr class) but could be an image or whatever. $langswitch = ''; foreach($languages as $language) { if(!$page->viewable($language)) continue; // is page viewable in this language? if($language->id == $user->language->id) { // current user language $langswitch .= "<li class='current'>"; } else { $langswitch .= "<li>"; } $url = $page->localUrl($language); $hreflang = $homepage->getLanguageValue($language, 'name'); $langswitch .= "<a hreflang='$hreflang' href='$url'>$language->title<b class='gf-if gspr {$language->name}'></b></a></li>"; } echo "<ul class='langswitch'>{$langswitch}</ul>"; -
-
okay ? PS: to update the modules directory, just re-submit the module and the module will be updated automatically in a second.
-
Installed a stock ProcessWire 3.0.102 I Downloaded the module RockFinder 1.0.0 I installed RockFinder I installed ProcessRockFinder I clicked Setup > RockFinder tester I have the same warning / error. Just for testing I replaced InputfieldRockGrid on line 50 by InputfieldTextarea, I can access the process module.
-
ProcessWire 3.0.98 PHP 7.0.10 I just installed the module from your Gitlab repo then I clicked Setup > RockFinder tester and the error happen. I think you can't reproduce this error because you have InputfieldRockGrid (called at line 50 in ProcessRockFinder.module.php) but its not shipped with module. That explain the warning. wow those smileys are big lol
-
Please submit this gold module to the modules directory so we can update it in one click ? Edit: Just re-installed the module from scratch, I got an error when I try to access the RockFinder tester, see the attached screenshot :
-
Already glad you switched from WP to PW ???
-
I think I am missing something, because to achieve what you asked, you have to write : [...] foreach($stories as $story) { if(count($page->imagefieldname)) { // images exist, we show the div echo "<div>...</div>"; } [...] } [...]
-
I am out of idea right now - I have 15 minutes, if you want I can take a look at your install if you feel confident.. Edit: was a browser cache issue.
-
Sorry, I don't understand what you mean by 'post archive'. The if condition you write, only work if the imagefieldname field is configured to contain a max of one (1) image. It is the case ?
-
You might have modified your .htaccess file to work on localhost and a subdirectory. Now, you should double check the .htaccess file, in particular this section : # ----------------------------------------------------------------------------------------------- # 11. OPTIONAL: Set a rewrite base if rewrites aren't working properly on your server. # And if your site directory starts with a "~" you will most likely have to use this. # ----------------------------------------------------------------------------------------------- RewriteBase / # RewriteBase /pw/ # RewriteBase /~user/ How is looking your ?
-
try updating your config.php with your new site url : $config->httpHosts = array('your.newsite.com');
-
Hi, more infos: https://processwire.com/api/fieldtypes/images/