-
Posts
5,039 -
Joined
-
Days Won
340
Everything posted by Robin S
-
Fatal error when moving site from localhost to Hosting
Robin S replied to Krlos's topic in Getting Started
Not working as in fatal error or as in no menu? I take it that there are some pages in your top level that you don't want to include in the menu - can you describe what you're trying to achieve? -
Fatal error when moving site from localhost to Hosting
Robin S replied to Krlos's topic in Getting Started
Are you sure you're using the "selector_field" option correctly? What is the contents of this field on pages where you are using it - is it a valid selector? I would consider "selector_field" to be an advanced option that isn't needed for most menus. For most situations the "selector" option is sufficient. -
In /site/init.php... $config->css_files = new \ProcessWire\FilenameArray(); $config->js_files = new \ProcessWire\FilenameArray(); In your Hanna Code PHP... $config->css_files->add('/site/templates/path/to/file.css'); $config->js_files->add('/site/templates/path/to/file.js'); Wherever you output your <head>... foreach($config->css_files as $css_file) { echo "<link rel='stylesheet' href='$css_file'>"; } foreach($config->js_files as $js_file) { echo "<script src='$js_file'></script>"; } See the code for the FilenameArray methods available: prepend(), remove(), removeAll(), etc. P.S. you can use the existing core $config->styles and $config->scripts FilenameArrays but other files might be added to these by certain modules so cleaner to create your own FilenameArrays I think.
-
Just used this snippet - really great solution!
-
I think the problem here is the way you are mixing PHP and HTML together: <? foreach($page->home_sliders as $home_slider) { <li class='orbit-slide'> This isn't valid PHP - you need to either echo all the HTML or switch in and out of PHP like so... <?php foreach($page->home_sliders as $home_slider): ?> <li class="orbit-slide"> ...more HTML... <?php endforeach; ?> As an aside, the short PHP open tag <? is discouraged - the short echo tag <?= is okay though.
-
get all unique values from a page field in all pages …
Robin S replied to ngrmm's topic in API & Templates
Better to store the selected pages in a PageArray: $children = $page->children; $uniques = new \ProcessWire\PageArray(); // assumes PW3 foreach($children as $child) { $uniques->import($child->size); } $uniques->sort("title"); foreach($uniques as $unique) { echo "<button class='filter' data-filter='.size_{$unique->title}'>{$unique->title}</button>"; } -
In a related topic in the ProFields sub-forum @ryan has said: So please log any SQL mode issues at GitHub as they arise so they can be tracked and resolved.
-
Integrating photos with wrapper folders and JS/XML dependencies
Robin S replied to Peter Knight's topic in General Support
If you mean they display content from your web server in an iframe then it doesn't matter what server technology is involved (PW or otherwise) because the iframe content loads on your server not theirs. You could use a URL segment such as /embed/ so that pages loaded with this segment do not include header, footer, etc but only the panorama content. Might not be something you want to tackle but just wanted to point out that it's possible. I'm not aware of any existing module that does this, but as I mentioned in an earlier post above wouldn't be difficult to create your own module that lists directories as options in a select field. The trick is getting the names of the valid directories you want to include as options into an $options array. -
Two possible solutions for your author/member pages: 1. Use separate templates for your author and member pages. For the author Page field (used in the publi template) your "Custom selector to find selectable pages" is: template=author|member To differentiate between author and member in your foreach loop: if($item->template->name == 'member') { // do something only for members } 2. Only use a single template for all authors (including members), but add a checkbox field 'member' to the author template to signal if the author is a member or not. To differentiate between author and member in your foreach loop: if($item->member == 1) { // do something only for members }
-
Using $page->render() to render the page with its template file (or another file you specify) has been around much longer than the $page->render('some_field') introduced in PW3 but the documentation has been a bit lacking. The cheatsheet doesn't help much and it's not covered in the new API reference - the best explanation I have found is this post from Ryan. Personally I think it would be clearer if individual fields were rendered exclusively with $page->renderField(). Using the existing $page->render() method when that was previously used for rendering whole pages with different options (e.g. the ability to pass your own array of variables) leads to some confusion.
-
I think you access the array with $options rather than $page->options.
-
$author = $pages->find("template=member, title=$page"); This part doesn't make sense unless you have a page using the member template whose title is a page ID. I don't think you need this line.
-
Integrating photos with wrapper folders and JS/XML dependencies
Robin S replied to Peter Knight's topic in General Support
More thoughts... 1. Could you reproduce the path to the PW page as a folder structure inside /site/templates? If your page is at mydomain.com/gallery/location-1/pano-1/ then you put the dependent files in /site/templates/gallery/location-1/pano-1/ and build the path to the files with: $config->paths->templates . $page->path() Then you don't need to select a folder in the PW admin (you just have to remember to upload your files to the right folder). 2. I reckon that by inspecting the code in the dependent files you'll be able to work out how to output it directly from your template file. Then you don't need to deal with these folders of dependent files at all - just upload the images to an image field on your page. Could you share an example of one of these pano folders so we can see what's in the code? -
$page->render("some_field") is an alias for $page->renderField(), and passing in an array of your own variables is not supported currently. I agree that it would be useful and have opened a feature request on GitHub.
-
For a Map Marker field named 'map'... function renderLocationsXML($locations) { $out = '<?xml version="1.0" encoding="utf-8"?>'; $out .= '\n<markers>'; foreach ($locations as $location) { // use any fields of $location $out .= "<marker name='{$location->title}' lat='{$location->map->lat}' lng='{$location->map->lng}' />"; } $out .= '\n</markers>'; return $out; } $locations = $pages->find("template=location"); header("Content-Type: text/xml"); echo renderLocationXML($locations);
-
Or: // get publication from this author $publi = $pages->find("template=publication, author=$page"); Author and Member are the same thing, right?
-
I get the reason for having manual control of where links/abbreviations appear, but what do you think about adding an option where terms are replaced automatically? It would be nice to give the user the ability to add new terms to the glossary without having to go through all their pages looking for where the term appears and adding the ||term|| syntax manually.
-
I believe the lazy cron can be triggered on every pageload by every user, including guest, and you don't need to add the db-backup permission to guest for this to happen. I asked about this too and @kixe responded... Agreed. Also, the module description on GitHub and the modules directory seems to contradict the above so perhaps that needs to be corrected?
-
CKEditor Feature Parity with Replaced Components
Robin S replied to Jason Huck's topic in Wishlist & Roadmap
Technically you can specify a subject line in the PW link dialog, but there isn't a dedicated field for it. mailto:me@mydomain.com?subject=my subject line -
Just wanted to add that if, as in the OP's case, you are going to foreach the children then there is no additional penalty to using $page->children()->count() because you will be loading the children into memory anyway.
-
I gotta say, how awesome is that we're in a community where we can hire PW's main man to help with our projects?! Like, can you imagine a world where you can't decide on your Facebook cover image so you call in Zuckerberg for a consult?
-
A couple of errors in your function... $output .="<h1><?php echo $page->title; ?></h1>"; The PHP tags shouldn't be here and you cannot echo inside a variable declaration. {$pages->about} ... {$pages->maincopy} These don't make sense - maybe you meant $page ? And totally a matter of preference, but I find... $output = " <div class='container'> <div class='row'> <div class='col-md-12'> <h1>{$page->title}</h1> </div> </div> </div> "; ...more readable than... $output = ""; $output .="<div class=\"container\">"; $output .="<div class=\"row\">"; $output .="<div class=\"col-md-12\">"; $output .="<h1>{$page->title}</h1>"; $output .="</div>"; $output .="</div>"; If you're considering switching to functions instead of includes because of performance concerns I wouldn't bother. It's true that you would avoid some file loads but you'd have to have a lot more includes before this would make a difference worth caring about. One thing to think about when considering a switch from includes to functions is variable scope. Basically, includes have access to variables defined outside of them but functions do not unless you pass the variable to the function as a parameter. This can be a help or a hindrance depending on your needs. Lastly, you could consider using $files->render() (aka wireRenderFile). A file rendered this way has access to all API variables and you can pass in an array of your own variables for use inside the file. I'm not 100% clear on the benefits of this over a normal include but I guess it has to do with the isolation of variable scope (to avoid the risk of overwriting variables of the same name in your template).
-
Rather than put the "hidden" class on a containing div I would put it on the thumbnail links that you don't want to show. $album_iteration = 1; foreach($page->album_repeater as $album) { $image_iteration = 1; foreach($album->album_images as $image) { $class = $image_iteration == 1 ? '' : ' hidden'; echo " <a class='fancybox{$class}' rel='gallery{$album_iteration}' title='Gallery {$album_iteration} - {$image_iteration}' href='{$image->size(800,800,array('cropping'=>false))->url}'> <img src='{$image->size(200,200)->url}' alt=''/> </a> "; $image_iteration++; } $album_iteration++; }
-
Saving certain pages brings me to a 404 error
Robin S replied to Thomasaur's topic in General Support
Sounds like nonsense to me - I've used many shared hosts and I've always been able to have mod security disabled for individual accounts. Maybe time to look for a new host? GoDaddy are not generally known for hosting excellence.