Jump to content

blynx

Members
  • Posts

    174
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by blynx

  1. Nice!!! I'm glad it works nicely for you! If you insist on the beer I will send you my paypal address ;P
  2. My few cents: I recently began to make a clearer distinction between the templates folder and the site folder. So anything in templates shall just be real "templates" and related stuff for the frontend. Though the template files function as controllers. But well, thats processwire ... In site/ I now have vendor/ with composer packages—because they are no templates, of course—and include them in site/init.php. There is also a /site/functions.php ... my own 'classes' become processwire modules. In templates: php related: /fields /components (like fields but with some extra functionality ... work in progress ... anything can be here. parts, snippets, head, partials, js css and php is bundled and provided together) /emails (html email templates to render maybe) /padloper (if I use padloper) /layouts (main "framing" templates for delayed output method) /forms (some custom forms?) other /scripts /styles /... Edit: If you are new, you might want to check out this blog entry about site/init.php or site/ready.php ... https://processwire.com/blog/posts/processwire-2.6.7-core-updates-and-more/ Huh, I am recommending the same blog entries all the time - but they really helped me structuring my processwire sites. (It's nice to rely on processwires own ways - like a best practice built in .... or so .... whatever ....)
  3. Try it out! There is no definite solution ... Just remeber to keep markup always in .php files - I often put side-wide options into the home template. But if they are not relevant for the editor it is probably better to put them into the .php files. For example you could add options to the $config variable in init.php <?php $config->my_site_options = array(); $config->my_site_options['nice-color'] = '#123456';
  4. Do you mean to put HTML code into a field in the admin backend? Don't do it. It is probably 'bad design'. Anything in your fields / pages should be just content. Anything markup should probably be some php file under your templates folder. A common approach is a "partials" folder where one could store snippets of markup which can be placed here and there. Have a look at these methods: http://processwire.com/api/ref/files/render/ http://processwire.com/api/ref/page/render-field/ http://processwire.com/api/ref/page/render-value/ http://processwire.com/api/ref/files/include/ They all have the purpose to render some .php file in one way or the other - or html markup. Quick example: // templates/template-file.php <?php namespace ProcessWire; $output = $files->render('snippets/sidebar.php', ['hello' => 'hello world!']); include('./layouts/layout.php') // delayed output ?> // /templates/snippets/sidebar.php <div id="sidebar"> <?= $hello ?> </div> // /templates/layouts/layout.php <html> <body> <?= $output ?> </body> </html> Sometimes it is good to not worry too much about the theoretical "right way" - I also often do. But often it just prevents me from actually learning right away Maybe post an example of the sidebar HTML you want to include - We / I could give you a better advice if we see the actual code because it is more clear what you are up to. cheers!
  5. Actually, I just remembered that I made a module which just aims for that, but relying on the new pages to inherit those "base settings" from parents. https://github.com/blynx/AdoptDefaultsFromParents What it is about: In the module settings, you can define templates that hand over the values of fields (which you also have to define) to newly created pages below them. Also, you can decide whether the new pages inherit the values only from the immediate parent or from the closest parent with that field. I used it for a shop - so that products inherit some values from their product-category (parent page). The product-category defines some basic common settings for the products then ... Yet, I haven't tested it with all sorts of fields - it might work well with that checkboxes field (options?) - it works with pagefields, simple texts, etc ... but not for images / files ... it simply copies the field value via setAndSave() You can have a look at the code there on the github page for inspiration - or even use the module if it suits you Or, here is the basic code to put into an /site/init.php file (see: https://processwire.com/blog/posts/processwire-2.6.7-core-updates-and-more/) <?php wire('pages')->addHookAfter('Pages::added', null, function() { $page = $event->arguments(0); if($page->template->name == 'my-template-name') { // save outputformatting state // and set to false $of = $page->of(); $page->of(false); $desired_value = ## my desire ## // set the desired field value $page->set('that-field-name', $desired_value); // save page // and re-set of to initial state $page->save(); $page->of($of); } }); cheers!
  6. Is it about fields in the admin/backend? A hack could be to preselect the desired checkboxes with a hook on Pages::added() Assuming it is only relevant to have the preselection on new pages. Which would go into the direction of Zekas quote of Ryan above:
  7. Oh, and just a little addition / inspiration for the delayed output: I also have a /templates/layouts/ folder were I have different "main.inc"s in case the resulting layout has fundamental differences. /layouts/layout-basic.php /layouts/layout-home.php most of the time thats enough ...
  8. Hm, why would chunks in the database be more secure? Usually I am trying to use the $page->render() method as often as possible. You will have reusable components in the tempaltes/fields/ folder then - image galleries, navigations, etc ... also I am using the delayed output method: https://processwire.com/docs/tutorials/how-to-structure-your-template-files/page4 Right now I am beginning to build my own "renderComponent()" function similar to $page->render which handles this, and also automatically includes css and js files which are placed like /templates/components/navigation/navigation.php /templates/components/navigation/navigation.css /templates/components/navigation/navigation.js ... and later it shall also handle require.js automatically. ... And I am dreaming about a "require.css" thingy. ... and then put it into a module ... or so. But it is pretty much up to you, processwire is very open in that respect - you should just start and see where it will lead you. You will better understand the pros and cons when you relly have tried and felt them Also, I think you will get into PHP very quickly by using processwire - just like in my case ...
  9. Welcome @MilenKo! A small question: Where did you actually find/get that theme? It looks really comprehensive and interesting! I'd also recommend looking into: https://processwire.com/blog/posts/processwire-3.0.7-expands-field-rendering-page-path-history-and-more/ "Field rendering with template files" good luck!
  10. Yup yup, actually I also think it's quite odd what I wanted to do from the languages standpoint. I had a look into this discussion then: http://stackoverflow.com/questions/7026487/how-to-add-methods-dynamically I haven't tried anything of that stuff there since I just use the class directly now, but maybe it is somehow possible with __call() and http://php.net/manual/en/function.get-class-methods.php
  11. Hi, given there is a class with some namespace like "Super\Project\NiceClass", how could I put that class into a module so that when I load that module via "$nice = $modules->get('NiceClass')", $nice is an instance of that class. I think thats simple but failed somehow - I tried to return the instance in the constructor or in the init() function, also in a separate function of that module - but had no luck. Any hint would be nice, thanks!
  12. Hah. Someone was faster. Tip for the terminal: To get to that directory you can enter "cd " (cd with a space) and then drag the folder where the htaccess.txt is located into the terminal window. Hit enter. Then the terminal switched to that directory. Then you can use the "mv" command adrian posted above.
  13. Ah! Yea as soon as I finished the answer I as starting to realize that. Well, basically I would put a form into a specific template - that template also receives the sent form and processes it. Have a look into this thread about creating forms using the processwire API: That's almost everything you need, you just need to add your markup and the Mailgun. (Here is further documentation of $input: https://processwire.com/api/ref/input/) ... although you will hardly need that because you can also get the values through the $form then ... as you can see in the example
  14. Hej, WireMailMailgun seems to be able to handle mail attachments. So, this should work. https://github.com/plauclair/WireMailMailgun But your question is also very vague cheers
  15. Mh, what kind of field is author? If thats a Page field, try author.title=... Also, what FieldType is alias? I assume Text?
  16. Hej, without having read the whole post, just a quick reply about preg_replace() and regular expressions - it is definately useful to learn that stuff! Have a look at these sites: http://www.phpliveregex.com regular expressions in php and the according php functions http://www.regexr.com live editing of regular expressions - very nice to learn Regular expressions let you search for patterns in strings. E.g. you have a link <a href='url'></a> And then you could write some code which identifies the 'url' part and replaces it with 'url#anchor' - for example. And in your case you could limit that to the first level - it might be a bit tricky - but that topic is good to know anyway. Will get back to you later, have to go Edit: Ah, and the "hard coding" needn't be that "hard coded". Sometimes I use a pagefield on the homepage to let the user add items to the menu (which is based on that pagefield). Subpages could be generated depending on themplate or so - but that depends on your whole site concept. ... But there are many possibilieties!
  17. Hej, Ah, I also just see that of course you also need the url in the first level ... Maybe then, instead of using MarkupSimpleNavigation it will probably be easier to build the navigation by yourself - If the navigation is not overly complex-dynamic and you only have those items and maybe one dropdown it might be just fine to hard-code the navigation. Could you paste the code of resulting navigation and the whole MarkupSimpleNavigation setup code here? Another approach could be to modify the MarkupSimpleNavigation afterwards with preg_replace() - to find the links in the first level and modify the href to add the proper #anchor.
  18. Hej, Hm, sorry - no idea so far, roles and permissions ok? Maybe try an update? (backup before ...) but you could do some more research with https://processwire.com/blog/posts/introducing-tracy-debugger/, just install it, activate it in the backend, too, and see if it reports anything suspicious in the bar. (don't bother the many configs ...)
  19. Hm, this is weird: The # (Anchor thingy) should definitely be after the url → href="{url}#....." or if you don't want to jump anywhere there doesn't need to be a # at all - in that code you just posted you can simply remove it. Maybe this is useful for understanding, possible "href"s: href="/link/to/some/page" — a link to another page href="#sectionA" — a "jumplink" / anchor to an element with the id on the same page! href="/other/page/#contact-form" — go to antother page and jump to that element with the id "contact-form" Try this: href={url}#{name} At first I was confused why your navigation worked apart from the dropdown. Because it shouldn't. But then I realised that you are "accidentally" using the same word for the section id as there is for the page name ... and the url is based on the page name. Instead of using the urls for as an id I would use the page name in combination with the id. So you get a unique identifier for the anchor. → #{name}-{id} The problem is that you don't want urls for the sections on the homepage in your <a>, you want something like <a href="#sectionB"> ... 'item_tpl' => '<a href="#{name}">{title}</a>' But you want urls for the dropdown things - and maybe jump link? maybe not? So you would want something like <a href="/page/"> or <a href="/page/#anchor"> ... 'item_tpl' => '<a href="{url}#">{title}</a>' or ... 'item_tpl' => '<a href="{url}#{name}">{title}</a>' Have a look again at MarkupSimpleNavigation Documentation: <?php 'xtemplates' => '', // specify one or more templates separated with a pipe | to use the xitem_tpl and xitem_current_tpl markup 'xitem_tpl' => '<a href="{url}">{title}</a>', // same as 'item_tpl' but for xtemplates pages, can be used to define placeholders 'xitem_current_tpl' => '<span>{title}</span>', // same as 'item_current_tpl' but for xtemplates pages With the xtemplates option you can define another kind of link template for specific page templates. Sorry, might be a bit confusing with the {name} and {id} - hope this helps anyway
  20. Just want to add some more keywords to this thread. I also installed processwire on an 1und1 server and got an Internal Server Error for any subpages iNoize had the solution (quoted above)
  21. Regarding MarkupSimpleNavigation: You have more options here: http://modules.processwire.com/modules/markup-simple-navigation/ (See Default Options) Including the options to modify the markup of the links: <?php $options = array( ... 'item_tpl' => '<a href="{url}#section{id}">{title}</a>', 'item_current_tpl' => '<a href="{url}#section{id}" class="current">{title}</a>', ... ); echo $treeMenu->render($options, [...], [...]); I also go with @Webrockers method of having the sections of onepagers as childpages of the homepage. (Or they could sit anywhere basically). It is nice because you can have different templates for each kind of section then: "onepager_text, onepager_carousel, onepager_contact". Find them with the selector ("template=onepager_text|onepager_carousel|onepager_contact")
  22. @Juergen This might be interesting: https://developer.mozilla.org/en-US/docs/Web/CSS/:valid and :invalid Or you could add a class like "submitted" to the form after it has been submitted once. Then you would know that the inputs without error are valid.
  23. niiiiiice, glad it worked right away! You're very welcome! also let's worship Ryan and contributors, for the brilliant architecture of processwire making it possible! ^~^
×
×
  • Create New...