blynx / MarkupProcesswirePhotoswipe

MarkupProcesswirePhotoswipe is a module for an easy yet customizable image gallery integration into your ProcessWire website. It uses Photoswipe by Dmitry Semenov, @dimsemenov, a very very good Javascript gallery which does not depend on jQuery or anything else.
Other
13 stars 3 forks source link

wrong css path / Undefined index: alt #3

Open Smirftsch opened 6 years ago

Smirftsch commented 6 years ago

Hey, thanks for the plugin! Unfortunately I couldn't make it work yet, but I am also pretty new to Processwire at all, so this may be a problem on my end as well. First issue I have is, that I am using processwire not in document root on the page, but in some subdirectory called processwire. It seems the css path is wrong as it does seem to miss the subdirectory processwire:

<link rel="stylesheet" type="text/css" href="/processwire/site/templates/styles/main.css" />
<link rel="stylesheet" type="text/css" href="/site/modules/MarkupProcesswirePhotoswipe/photoswipe/photoswipe.css">
<link rel="stylesheet" type="text/css" href="/site/modules/MarkupProcesswirePhotoswipe/photoswipe/default-skin/default-skin.css">
<link rel="stylesheet" type="text/css" href="/site/modules/MarkupProcesswirePhotoswipe/MarkupPwpswpGalleryHorizontalScroller.css">

Edited: The path to $scriptUrl seems to miss the subdirectory too.

second problem I have is that I always get Notice: Undefined index: alt in /opt/users/www/html/processwire/site/modules/MarkupProcesswirePhotoswipe/MarkupPwpswpGallery.module on line 168

No matter what I try. Editing line 168 to $imageData['alt'] = $image->alt ?: $imageData['description']; silences this warning, but I am not really sure if this would be correct approach.

Using PHP7.0.21 right now and processwire 3.0.98 if this is of any importance

blynx commented 6 years ago

Hi, thanks for the report here! I'm pretty busy right now - I try to get into this next week, sorry for that.

Though, do you get the correct urls when you fetch an image manually on a template? Something like $page->imagefield?->someImage?->url(). So far I only read briefly about putting processwire into a subdirectory and I think there are a some threads about problems like this in the forum alreay. Maybe there is actually a way to solve this rather by configuring processwire instead of touching the module ... not sure

The solution for the notice seems fine - haven't looked at the code for a while now, but if it works for you then it seems to be good :)

rSSi commented 6 years ago

Thank you for the plugin! I just wanted to use Photoswipe with my Processwire install and by accident found your module :) I got the same issues and looked into the Undefined Index -> Smirftsch's edit is correct. $imageData['alt'] is undefined and we want to define it: $imageData['alt'] = $image->alt ?: $imageData['description'];

I have to look into the path problem because I am also using a subfolder to develop my site and move it as soon as i want to publish the new site. I'm trying to find the solution to the path problem..

Kholja commented 6 years ago

Hello Blynx - thanks for the plugin. Regarding the Issue "wrong paths for css and js". This will come up when installing PW in a subdirectory. Easy fix to bring up correct paths is i.e. by adding: $this->moduleUrl = $this->rootUrl.$this->moduleUrl; after line 88 $this->rootUrl = $config->urls->root;

Kholja commented 6 years ago

... and to find the correct paths of css and js files of other gallery types, in MarkupPwpswpGallery.module Line 71 should be: return wire('config')->urls->root.str_replace($this->rootPath, '/', $file); instead of return str_replace($this->rootPath, '/', $file);

blynx commented 6 years ago

Damn, totally forgot about this one. Will definitely get into it these days! Have some free time right now - thanks for the hints so far and sorry for the delaaaay.