Jump to content

Manuel

Members
  • Posts

    19
  • Joined

  • Last visited

Everything posted by Manuel

  1. A very neat project to learn from! You really should deliver the pictures in a a resized version and activate lazy-loading (at least native lazyloading). <img src="image.jpg" loading="lazy" alt="..." /> For now, the whole site has about 226 requests and needs to download about 113MB (!!!) of files.
  2. Thanks a lot @BitPoet and @Edison for your suport - I knew there would be a smarter way. ?
  3. Hi again, after testing the script with the ?? Null coalescing operator I know it's not working, because it checks if a var is set (yeah it's always set, even when it's empty...) So I came up with another solution, wich is still a bit unwieldy - but it's doing it's job. <?php echo !empty($page->meta_description) ? $page->meta_description : $pages(1)->meta_description; ?> <?php echo !empty($page->meta_keywords) ? $page->meta_keywords : $pages(1)->meta_keywords; ?> Maybe we get a better snippet for that sort of code... Have a nice evening!
  4. Hi @Edison, That's the solution (PHP7 / Null coalescing operator) I'm using right now, while using PW i've learned there is very often a shorter or build-in way to solve that kind of problems. Thank you any way ?
  5. Hi there! I'm using two fields on multiple pages, called "meta_keywords" and "meta_description". You're right, I'm using them for individual meta-tags on every page. Here's my question: Is there a smart way using $page->get(), to recieve a standard value from a specific page, if the page itself, does not have a value? I'm looking for something like this: <?php echo $page->get('meta_description|page(1).meta_description'); Unfortunately this syntax will not work, but i hope you get the idea. page(1) would be the standard-value from the page with the id 1. Thanks for any ideas, Manuel
  6. Thank you very much, for writing me those detailed information! @Klenkes and @wbmnfktr , I really appreciate that!
  7. For this purpose, a switch-statement would be a bit more readable and faster. If there are more than 3 conditions to check (one var with different values), you should use switch. Switch is also slightly faster, because it just computes the condition once and then checks for the output while if / elseif / else has to be computed every time.
  8. Dear Community, after diving into Processwire and developing my first PW-based project, I've read about the commercial plugins. I know, choosing the right plugin depends on the project but: What Pro-Plugins do the experienced users recommend? Wich Pro-Plugins do you use most often in your projects? Thank you for sharing you experience! ?
  9. Thank you @bernhard I knew there would be a faster way to get the job done. PW is geeting better and better to me ?
  10. My final solution to output all fields as a JSON-Object: <?php $planets = $pages->find("template=planet, sort=-title"); $planets_array = array(); foreach($planets as $planet) { $moon_array = array(); $moons = $planet->planet_moons; foreach($moons as $moon) { $moon_array[] = $moon->title; } $planets_array[] = array( 'title' => $planet->title, 'created' => date("H:i:s d.m.Y", $planet->created), 'modified' => date("H:i:s d.m.Y", $planet->modified), 'type' => $planet->planet_type, 'age' => $planet->planet_age, 'color' => ucfirst($planet->planet_color->title), 'moons' => $moon_array, 'summary' => $planet->planet_summary, 'foto' => $_SERVER['SERVER_NAME'] . $planet->planet_foto->url, 'planet-reference' => $planet->planet_reference[0]->title ); } $planets_json = json_encode($planets_array, true); echo $planets_json; ?> Output (JSON): [{ "title": "Merkur", "created": "20:25:29 16.04.2019", "modified": "14:06:19 17.04.2019", "type": "W\u00fcstenplanet", "age": "800.812", "color": "Brown", "moons": ["Merkur Mond 1", "Merkur Mond 2"], "summary": "Beschreibung gibt es noch erst eine sehr kurze. hier gibt es noch nicht viel zu lesen...", "foto": "extranet\/site\/assets\/files\/1045\/merkur.jpg", "planet-reference": "Earth" }, { "title": "Mars", "created": "17:54:58 07.04.2019", "modified": "14:06:08 17.04.2019", "type": "Terrestrial moon", "age": "4.500.000.712", "color": "Red", "moons": ["Phobos", "Deimos"], "summary": "Mars is the fourth round planet from the Sun...", "foto": "extranet\/site\/assets\/files\/1018\/mars.jpg", "planet-reference": "Merkur" }, { "title": "Jupiter", "created": "17:28:14 07.04.2019", "modified": "14:05:52 17.04.2019", "type": "Great Gas Giant", "age": "4,5 Billion", "color": "Yellow", "moons": ["Io", "Europa", "Kallisto", "Ganymed", "Amalthea", "Himalia", "Elara"], "summary": "Jupiter is the fifth planet...", "foto": "extranet\/site\/assets\/files\/1017\/jupiter.jpg", "planet-reference": "Mars" }, { "title": "Earth", "created": "17:13:23 07.04.2019", "modified": "14:05:40 17.04.2019", "type": "Terrestrial Planet", "age": "15.56 Billion", "color": "Purple", "moons": ["Moon"], "summary": "Earth (or the Earth) is the third planet from the Sun...", "foto": "extranet\/site\/assets\/files\/1016\/earth-1.jpg", "planet-reference": "Jupiter" }]
  11. You're right, a select-input would be a neat workaround to prevent a user to assign multiple pages. I agree, issue should be fixed. As a newbie tat behaviour was a bit confusing to me. Thanks to everybodies help: @Robin S @adrian @BitPoet @bernhard ?
  12. Switching the field to Multiple Pages works fine, but for now the user is able to assign multiple planets instead of just one ?
  13. Hi @Robin S, that would make sense. But after checking the references (only 4 pages), I can tell you they don't reference each other. Here's another screenshot. The references are as follows: earth (1016) --> mars (1017) mars(1017) --> jupiter (1018) jupiter(1018) --> merkur (1045) merkur(1045) --> earth(1016) After removing one of the d() functions as shown above, the fatal error doesn't occure. The problem is, I want to get all pages with there references, not only n-1 ?
  14. No problem and thanks for your advise! I'll try to solve the issue and will report the solution in this thread - hopefully ?
  15. @bernhard now i know what you mean. No - there is another id selected (1017). PW even doesn't offer a self-refference in the selectbox.
  16. Thank you for the hints! Unfortunately the error occures on every page, also on the backend (TracyDebugger Console).
  17. Hi @bernhard - and greetings from Tirol ? Yes I've allready installed Tracy-Debugger and get the same error. It can't be an endless loop, because, even if I enter the code directly into the tracy debugger console, the same error happens. Two outputs work fine, after a third one a error occurs... Thanks for your help! Manuel
  18. Hi everybody! I'm new to PW and just did the beginner-tutorial “Hello Worlds”, a beginning ProcessWire tutorial --> Link After extending the template from the original tutorial with a page_reference-Field (Page-Field value type is configured as single page), PW throws a fatal error when i try to output multiple pages: $planets = $pages->find("template=planet, sort=-title"); foreach($planets as $planet) { echo $planet->title; echo $planet->planet_reference->title; } Should return three Pages, but throws the following error: When i try to output the field with a single page, everything just works fine: $planet = $pages->get(1018); echo $planet->title; echo $planet->planet_reference->title; I've tried to solve the problem with myself (and google), but i can't fix the error. Thanks a lot! My enviroment: OSX Mojave / MAMP (PHP 7.2), PW v 3.0.123
×
×
  • Create New...