-
Posts
20 -
Joined
-
Last visited
Everything posted by VirtuallyCreative
-
Can't access $homepage while in user.php?
VirtuallyCreative replied to VirtuallyCreative's topic in General Support
@Robin S Well that would explain a lot! Thank you. -
Can't access $homepage while in user.php?
VirtuallyCreative replied to VirtuallyCreative's topic in General Support
Thanks @ottogal I'll give this a shot! -
Hello PW Community, I'm currently creating a custom profile page that overrides the default template (using user.php file). I noticed however that when I tried to load user.php any calls I have to $homepage broke (my main navigation area). Here is the snippet that doesn't work on user.php, but works everywhere else: <!-- BEGIN SIDEBAR MENU ITEMS--> <ul class="menu-items"> <?php // top navigation consists of homepage and its visible children foreach($homepage->and($homepage->children) as $child) { echo "<li class=''><a href='". ($child->hasChildren() ? "javascript:;" : $child->url) ."'><span class='title'>$child->title</span>"; if($child->hasChildren()) { echo "<span class='arrow'></span></a>"; //loop through the top navigation child's children pages and output them as nested menu item foreach($child->children as $childitem) { echo "<ul class='sub-menu'>"; echo "<li class=''><a href='$childitem->url'>$childitem->title</a>"; echo "</a><span class='icon-thumbnail'>"; echo substr($childitem->title, 0, 2); echo "</span></li></ul>"; } } //step back out and continue listing Homepage Children pages if($child->id == $page->rootParent->id) { echo "</a><span class='bg-success icon-thumbnail'>"; echo substr($child->title, 0, 2); echo "</span></li>"; } else { echo "</a><span class='icon-thumbnail'>"; echo substr($child->title, 0, 2); echo "</span></li>"; } } ?> </ul> <div class="clearfix"></div> </div> <!-- END SIDEBAR MENU --> it outputs a menu and works on all template pages except for user.php. *note that $homepage is defined in _init.php and is loaded before user.php as I left the append to default. Do I have to specifically tell _init.php to append to user.php template? // We refer to our homepage a few times in our site, so we preload a copy // here in a $homepage variable for convenience. $homepage = $pages->get('/'); The error I get is saying the issue is with the first foreach($homepage->and($homepage->children) as $child) line (93), but I thought it would be defined because user.php pulls in _init.php first? Notice: Undefined variable: homepage in /var/www/html/site/templates/user.php on line 93 Fatal error: Uncaught Error: Call to a member function and() on null in /var/www/html/site/templates/user.php:93 Stack trace: #0 /var/www/html/wire/core/TemplateFile.php(268): require() #1 [internal function]: ProcessWire\TemplateFile->___render() #2 /var/www/html/wire/core/Wire.php(374): call_user_func_array(Array, Array) #3 /var/www/html/wire/core/WireHooks.php(549): ProcessWire\Wire->_callMethod('___render', Array) #4 /var/www/html/wire/core/Wire.php(399): ProcessWire\WireHooks->runHooks(Object(ProcessWire\TemplateFile), 'render', Array) #5 /var/www/html/wire/modules/PageRender.module(514): ProcessWire\Wire->__call('render', Array) #6 [internal function]: ProcessWire\PageRender->___renderPage(Object(ProcessWire\HookEvent)) #7 /var/www/html/wire/core/Wire.php(374): call_user_func_array(Array, Array) #8 /var/www/html/wire/core/WireHooks.php(549): ProcessWire\Wire->_callMethod('___renderPage', Array) #9 /var/www/html/wire/core/Wire.php(399): ProcessWire\WireHooks->runHooks(Object(ProcessWire\PageRender), 'renderPage', Arr in /var/www/html/site/templates/user.php on line 93 Error: Uncaught Error: Call to a member function and() on null in /var/www/html/site/templates/user.php:93 Stack trace: #0 /var/www/html/wire/core/TemplateFile.php(268): require() #1 [internal function]: ProcessWire\TemplateFile->___render() #2 /var/www/html/wire/core/Wire.php(374): call_user_func_array(Array, Array) #3 /var/www/html/wire/core/WireHooks.php(549): ProcessWire\Wire->_callMethod('___render', Array) #4 /var/www/html/wire/core/Wire.php(399): ProcessWire\WireHooks->runHooks(Object(ProcessWire\TemplateFile), 'render', Array) #5 /var/www/html/wire/modules/PageRender.module(514): ProcessWire\Wire->__call('render', Array) #6 [internal function]: ProcessWire\PageRender->___renderPage(Object(ProcessWire\HookEvent)) #7 /var/www/html/wire/core/Wire.php(374): call_user_func_array(Array, Array) #8 /var/www/html/wire/core/WireHooks.php(549): ProcessWire\Wire->_callMethod('___renderPage', Array) #9 /var/www/html/wire/core/Wire.php(399): ProcessWire\WireHooks->runHooks(Object(ProcessWire\PageRender), 'renderPage', Arr (line 93 of /var/www/html/site/templates/user.php) This error message was shown because: site is in debug mode. ($config->debug = true; => /site/config.php). Error has been logged. Any insight anyone could provide would be appreciated! Lots to learn when using ProcessWire but it's a solid CMS and I'm really enjoying developing on the platform. Regards, VirtuallyCreative
-
Pulling in Gravatar Avatars
VirtuallyCreative replied to VirtuallyCreative's topic in Module/Plugin Development
@adrian thanks! That did the trick. I'll have to think of serving up a default avatar if no Gravatar exists and work that into the next version. Appreciate the help! -
Pulling in Gravatar Avatars
VirtuallyCreative replied to VirtuallyCreative's topic in Module/Plugin Development
thanks @adrian I'll re-work this a bit and see if I can get it going, my PHP is still weaksauce compared to my HTML/CSS/JS. Any ideas on a better approach? -
Hello PW Community, I'm trying to modify a small module I found to pull in Gravatars but I'm having a bit of an issue and was curious if someone has already done a Gravatar implementation, or could look over the module code? It installed no problem, but when I try to use it, nothing works. Here is the full module: <?php /** * Module for generating Gravatar URLs for ProcessWire users. * * Use it like this: * * Get URL only with all defaults: * $user->gravatar() * * Get image tag with different size: * $user->gravatar(array('img' => true, 's' => 200)); * */ class Gravatar extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Gravatar', 'version' => 1, 'summary' => 'Gravatar hook for users', 'singular' => true, 'autoload' => true, 'icon' => 'smile-o', ); } public function init() { $this->addHook('User::gravatar', $this, 'methodGravatar'); } public function methodGravatar($event) { $u = $event->object; if ( ! $u instanceof User) $event->return = false; return; if ( ! $u->email) $event->return = false; return; $params = ($event->arguments(0) ? $event->arguments(0) : array()); // Default options $defaults = array( 's' => 100, 'd' => 'retro', 'r' => 'g', 'img' => false, 'attrs' => array(), ); $opts = array_merge($defaults, $params); extract($opts); $url = '//www.gravatar.com/avatar/'; $url .= md5(strtolower(trim($u->email))); $url .= "?s=$s&d=$d&r=$r"; if ($img) { $url = '<img src="' . $url . '"'; foreach ($attrs as $key => $val ) { $url .= ' ' . $key . '="' . $val . '"'; } $url .= ' />'; } $event->return = $url; } } The issue is when I use $user->gravatar() I'm getting back "unknown". I know that the email being used by the current logged-in user (me) does have a Gravatar, but I'm unable to get the URL so I can place it into my template markup. Any insight or direction would be appreciated. I did a search for Gravatar modules / forum topics but it mostly appears to be linked to the Blog profile that uses Gravatar, not a stand-alone module / implementation. Regards, VirtuallyCreative
-
So being a LAMP server guy, recently at my work I've had to use Microsoft's' Azure Cloud to host some micro-apps of ours and I got to playing around with the platform. It's pretty nifty! Naturally, I tried to install ProcessWire to play around with Web Apps + SQL App Service to see what I can get away with on the Free Tier (rather then spinning up a full LAMP VM machine which is the way Bitnami installs ProcessWire, costing $60CAD/mo). Turns out installing ProcessWire is pretty smooth sailing except for one part: .htaccess mod_rewrite rules when you're not using Apache, as this is Azure Cloud so it's running PHP7 on IIS Microsoft Server and requires rewrite rules to be in a web.config file instead. Doing some digging, I found tools that convert .htaccess over to web.config and was curious if anyone with experience using Microsoft .NET could see if the rules from the .htaccess actually do translate in the same way when written in XML for web.config? Default ProcessWire v3.0 .htaccess file (comments, commented out commands removed): Options -Indexes Options +FollowSymLinks ErrorDocument 404 /index.php <Files favicon.ico> ErrorDocument 404 "The requested file favicon.ico was not found. </Files> <Files robots.txt> ErrorDocument 404 "The requested file robots.txt was not found. </Files> <IfModule mod_headers.c> Header always append X-Frame-Options SAMEORIGIN Header set X-XSS-Protection "1; mode=block" </IfModule> <FilesMatch "\.(inc|info|info\.json|module|sh|sql)$|^\..*$|composer\.(json|lock)$"> <IfModule mod_authz_core.c> Require all denied </IfModule> <IfModule !mod_authz_core.c> Order allow,deny </IfModule> </FilesMatch> <IfModule mod_php5.c> php_flag magic_quotes_gpc off php_flag magic_quotes_sybase off php_flag register_globals off </IfModule> DirectoryIndex index.php index.html index.htm <IfModule mod_rewrite.c> RewriteEngine On AddDefaultCharset UTF-8 <IfModule mod_env.c> SetEnv HTTP_MOD_REWRITE On </IfModule> RewriteRule "(^|/)\.(?!well-known)" - [F] RewriteCond %{REQUEST_URI} !(^|/)site-[^/]+/install/[^/]+\.(jpg|jpeg|png|gif)$ [OR] RewriteCond %{REQUEST_URI} (^|/)\.htaccess$ [NC,OR] RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/assets/(cache|logs|backups|sessions|config|install|tmp)($|/.*$) [OR] RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/install($|/.*$) [OR] RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/assets.*/-.+/.* [OR] RewriteCond %{REQUEST_URI} (^|/)(wire|site|site-[^/]+)/(config|index\.config|config-dev)\.php$ [OR] RewriteCond %{REQUEST_URI} (^|/)(wire|site|site-[^/]+)/templates-admin($|/|/.*\.(php|html?|tpl|inc))$ [OR] RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/templates($|/|/.*\.(php|html?|tpl|inc))$ [OR] RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/assets($|/|/.*\.php)$ [OR] RewriteCond %{REQUEST_URI} (^|/)wire/(core|modules)/.*\.(php|inc|tpl|module|info\.json)$ [OR] RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/modules/.*\.(php|inc|tpl|module|info\.json)$ [OR] RewriteCond %{REQUEST_URI} (^|/)(COPYRIGHT|INSTALL|README|htaccess)\.(txt|md|textile)$ [OR] RewriteCond %{REQUEST_URI} (^|/)site-default/ RewriteRule ^.*$ - [F,L] RewriteCond %{REQUEST_URI} "^/~?[-_.a-zA-Z0-9/]*$" [OR] RewriteCond %{REQUEST_FILENAME} !-f [OR] RewriteCond %{REQUEST_FILENAME} !-d [OR] RewriteCond %{REQUEST_FILENAME} !(favicon\.ico|robots\.txt) [OR] RewriteRule ^(.*)$ index.php?it=$1 [L,QSA] </IfModule> Converted web.config file: <rewrite> <rules> <rule name="www_mysite_com:non-80"> <match url=""(^|/)\.(?!well-known)"" ignoreCase="false" /> <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" /> </rule> <rule name="www_mysite_com:80" stopProcessing="true"> <match url="^.*$" ignoreCase="false" /> <conditions logicalGrouping="MatchAny"> <add input="{URL}" pattern="(^|/)site-[^/]+/install/[^/]+\.(jpg|jpeg|png|gif)$" ignoreCase="false" negate="true" /> <add input="{URL}" pattern="(^|/)\.htaccess$" /> <add input="{URL}" pattern="(^|/)(site|site-[^/]+)/assets/(cache|logs|backups|sessions|config|install|tmp)($|/.*$)" ignoreCase="false" /> <add input="{URL}" pattern="(^|/)(site|site-[^/]+)/install($|/.*$)" ignoreCase="false" /> <add input="{URL}" pattern="(^|/)(site|site-[^/]+)/assets.*/-.+/.*" ignoreCase="false" /> <add input="{URL}" pattern="(^|/)(wire|site|site-[^/]+)/(config|index\.config|config-dev)\.php$" ignoreCase="false" /> <add input="{URL}" pattern="(^|/)(wire|site|site-[^/]+)/templates-admin($|/|/.*\.(php|html?|tpl|inc))$" ignoreCase="false" /> <add input="{URL}" pattern="(^|/)(site|site-[^/]+)/templates($|/|/.*\.(php|html?|tpl|inc))$" ignoreCase="false" /> <add input="{URL}" pattern="(^|/)(site|site-[^/]+)/assets($|/|/.*\.php)$" ignoreCase="false" /> <add input="{URL}" pattern="(^|/)wire/(core|modules)/.*\.(php|inc|tpl|module|info\.json)$" ignoreCase="false" /> <add input="{URL}" pattern="(^|/)(site|site-[^/]+)/modules/.*\.(php|inc|tpl|module|info\.json)$" ignoreCase="false" /> <add input="{URL}" pattern="(^|/)(COPYRIGHT|INSTALL|README|htaccess)\.(txt|md|textile)$" ignoreCase="false" /> <add input="{URL}" pattern="(^|/)site-default/" ignoreCase="false" /> </conditions> <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" /> </rule> <rule name="www_mysite_com:80" stopProcessing="true"> <match url="^(.*)$" ignoreCase="false" /> <conditions logicalGrouping="MatchAny"> <add input="{URL}" pattern=""^/~?[-_.a-zA-Z0-9/]*$"" ignoreCase="false" /> <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" /> <add input="{REQUEST_FILENAME}" pattern="(favicon\.ico|robots\.txt)" ignoreCase="false" negate="true" /> </conditions> <action type="Rewrite" url="index.php?it={R:1}" appendQueryString="true" /> </rule> </rules> </rewrite>
- 3 replies
-
- 1
-
- azure cloud
- .htaccess
-
(and 1 more)
Tagged with:
-
ProcessWire Blank page issue!
VirtuallyCreative replied to VirtuallyCreative's topic in Getting Started
@kongondo, @flydev upon further review, I think the culprit was... myself. I also installed yoURLs in a sub-folder and I remembering messing with permissions during that script's install, and I thought I put them back to default probably not realizing the larger implications of doing so for ProcessWire as I was logged in as root rather then a sudo-enabled user. Noob moment. Few lessons learned for sure. -
ProcessWire Blank page issue!
VirtuallyCreative replied to VirtuallyCreative's topic in Getting Started
Solved by @flydev! Turns out I had the wrong permissions set for the top-level directory. Nothing to do with .htaccess as it turns out! All content of /var/www/html was attached to root's group. So a simple chown -R www-data:www-data /var/www/html did the trick. I just want to say that I'm so thankful for how helpful the ProcessWire dev community is and will make sure to pay it forward! -
ProcessWire Blank page issue!
VirtuallyCreative replied to VirtuallyCreative's topic in Getting Started
@matjazp During the install process, you're asked if you want to change the URL for the ProcessWire backend, which in doing so I assumed would update a rewrite rule inside the .htaccess. I suppose it doesn't now that I look at the default .htaccess file... -
ProcessWire Blank page issue!
VirtuallyCreative replied to VirtuallyCreative's topic in Getting Started
@matjazp Indeed, that is the puzzling question as I'm not sure what changed between Friday and Tuesday (was off Monday). The .htaccess file I was using is the default one from the /master/ branch of Github, nothing special no changes. And I'm running the latest version of PW (v3). The one non-default setting was I changed admin backend URL from default "/pw/" to "/admin/". So I suppose that would be reflected in the .htaccess file and not the default one so that's updated during install process? -
ProcessWire Blank page issue!
VirtuallyCreative replied to VirtuallyCreative's topic in Getting Started
@matjazp You are correct. I created a fresh .htaccess with just that and in trying to visit a bad url it forwards me to google. Still have a blank homepage however, and I can't access the /admin/ area at all. -
ProcessWire Blank page issue!
VirtuallyCreative replied to VirtuallyCreative's topic in Getting Started
Yup I'm editing the correct .htaccess file. I suppose caching could be on.. but it shouldn't be caching a .htaccess file, only .php pages? There are some .php pages in the /site/assets/cache/FileCompiler/site/ folder but I don't see any cached .htaccess file. I've just been scratching my head at this and I've lost a full day of development now because of it and I'm starting to get frustrated that I can't troubleshoot this better. -
ProcessWire Blank page issue!
VirtuallyCreative replied to VirtuallyCreative's topic in Getting Started
@matjazp the result of that command is: 00000000 23 20 2d 00000003 Does that mean the characters are still there? I'm not sure how to get rid of them if that's the case. I restarted Apache each time and I've open and saved the .htaccess file using Sublime Text, Notepad, Notepad++, VS Code. All of them say UTF-8 (no BOM) yet I still can't fix the file or get those characters to appear to erase them from the head of the .htaccess file. I appreciate your help. Regards, V(C) -
ProcessWire Blank page issue!
VirtuallyCreative replied to VirtuallyCreative's topic in Getting Started
@matjazp Ok I nuked my .htaccess file using the default one within processwire-master and re-uploaded it. Now I no longer get a blank page, but a 500 Server error screen. Progress! I'm still getting the .htaccess error in the error.log now but I'm not sure why it's not fixed... I opened the .htaccess file in notepad and make sure to save as "all files" type and with only UTF-8 but I'm still getting the same error it appears. If I touch the file using nano on the server via command line I don't see the "\exf\xbb\xbf" characters either. Is there something I'm missing to correct this issue?? [Tue Feb 14 21:23:40.284736 2017] [core:alert] [pid 2797] [client 67.211.127.12:14112] /var/www/html/.htaccess: Invalid command '\xef\xbb\xbf###...', perhaps misspelled or defined by a module not included in the server configuration -
ProcessWire Blank page issue!
VirtuallyCreative replied to VirtuallyCreative's topic in Getting Started
@adrian Yup, I have $config->debug = true; inside my config.php. I'm thinking it might still be an .htaccess issue, but at this point I'm unable to isolate it. If I rename .htaccess to htaccess.txt I then get a 500 internal server error going to any URL within processwire. I thought it was to do with the UTF-BOM encoding issue but I believe I corrected it by uploading a UTF-8 only encoded .htaccess file. -
Hello! I was working on my website on Friday with what appears everything to be fine, and I come back today and now I can't access any page, I just get a white page with no information and no logs are logging what the issue is and I'm quite stumped frankly as to the cause. Going to http://138.197.146.76/ just brings up a blank page and no error logs and it's driving me crazy trying to troubleshoot. If you go to any other non-processwire page it works fine, like the php info page: http://138.197.146.76/info.php At first I thought it was an .htaccess issue (UTF-8 BOM info being parsed by Apache2 a the head of the file) but in re-uploading it that didn't solve it. Then I thought it was a php error from the index page being loaded but no PHP errors appear anywhere that I can see with a timestamp near to today, nor does the Processwire log update. It hasn't updated since the 10th and I'm not sure why. After 10 years of WordPress development, I'm pretty decent at troubleshooting server issues but this just has me for a loop, I'm not sure what's going on here so if anyone has any insight or wouldn't mind taking a look to troubleshoot I can provide you with root access to the server (it's a Ubuntu 16 LTS droplet on Digital Ocean). I've included dumps of my most recent logs, maybe I'm missing a detail? Any insight would be appreciated! Regards, Virtually(Creative) errors.txt access.log error.log
-
Hello! I'm currently trying to create a navigation menu using list items and I'm having issues pulling children pages properly and I'm hoping someone can point me in the right direction. The code below was modified from the default (intermediate) template that outputs child pages of the main page. (Home -> About, SiteMap). But one of the children (About page), also has 3 child pages and I'm not sure how to also get those 3 additional child pages to display as well within the same foreach statement. Because of the way the menu is structured I would need to change the output of the HTML for any Child Page with additional Children (it nests underneath in the nav). Currently only Home, About and Sitemap appear and I want to also include the child pages of About nested properly within the navigation. Current code, only accounting for Homepage and it's children. Works great and as expected: Home About Sitemap <!-- START SIDEBAR MENU --> <div class="sidebar-menu"> <!-- BEGIN SIDEBAR MENU ITEMS--> <ul class="menu-items"> <?php // top navigation consists of homepage and its visible children foreach($homepage->and($homepage->children) as $item) { echo "<li class=''><a href='$item->url'><span class='title'>$item->title</span>"; // Grab first two letters of page to output for menu icon and set active class if($item->id == $page->rootParent->id) { echo "</a><span class='bg-success icon-thumbnail'>"; echo substr($item->title, 0, 2); echo "</span></li>"; } else { echo "</a><span class='icon-thumbnail'>"; echo substr($item->title, 0, 2); echo "</span></li>"; } } ?> </ul> <div class="clearfix"></div> </div> <!-- END SIDEBAR MENU --> Modified not working markup trying to also nest children of a child: Home About Page1 Page2 Page3 SiteMap <!-- START SIDEBAR MENU --> <div class="sidebar-menu"> <!-- BEGIN SIDEBAR MENU ITEMS--> <ul class="menu-items"> <?php // top navigation consists of homepage and its visible children foreach($homepage->and($homepage->children) as $item) { echo "<li class=''><a href='$item->url'><span class='title'>$item->title</span>"; // check if a top navigation item's visible children has child pages // if true, change markup of top navigation item to account for nested children if(($homepage->children)->hasChildren()) { //change menu item to menu item /w sub-items echo "<li class=''><a href='javascript:;'><span class='title'>$item->title</span> <span class='arrow'></span></a><span class='icon-thumbnail'><i class='pg-form'></i></span>"; //loop through the top navigation child's children pages and output them as nested menu item foreach($child->children as $childitem) { echo "<ul class='sub-menu'>"; echo "<li class=''><a href='$childitem->url'>$childitem->title</a>"; echo "</a><span class='icon-thumbnail'>"; echo substr($childitem->title, 0, 2); echo "</span></li></ul></li>"; } } //step back out and continue listing Homepage Children pages if($item->id == $page->rootParent->id) { echo "</a><span class='bg-success icon-thumbnail'>"; echo substr($item->title, 0, 2); echo "</span></li>"; } else { echo "</a><span class='icon-thumbnail'>"; echo substr($item->title, 0, 2); echo "</span></li>"; } } ?> </ul> <div class="clearfix"></div> </div> <!-- END SIDEBAR MENU --> Any insights would be appreciated! I'm also sure the php code itself can be refactored better but still learning for now.
-
@Robin S Thanks! That did the trick.
-
Hello! I'm quite new to PW (v3.0.42) and still a beginner with PHP. I'm looking to output the first two letters of a page's title. (So, if $page->title = "Home" I want to output "Ho". If someone could point me in the right direction that would be awesome!
-
User management is interesting in PW! Learning the best way to go about user registration / login.