Jump to content

VirtuallyCreative

Members
  • Content Count

    20
  • Joined

  • Last visited

Community Reputation

5 Neutral

About VirtuallyCreative

  • Rank
    Jr. Member
  • Birthday 05/20/1987

Contact Methods

  • Website URL
    http://virtuallycreative.ca
  • Skype
    vip3rousmango

Profile Information

  • Gender
    Male
  • Location
    Toronto, Canada
  • Interests
    Web Design & Development, Airsoft, Gaming

Recent Profile Visitors

1,307 profile views
  1. 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
  2. @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!
  3. 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?
  4. 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
  5. 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="&quot;(^|/)\.(?!well-known)&quot;" 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="&quot;^/~?[-_.a-zA-Z0-9/]*$&quot;" 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>
  6. @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.
  7. 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!
  8. @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...
  9. @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?
  10. @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.
  11. 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.
  12. @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)
  13. @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
×
×
  • Create New...