Jump to content

Jan Romero

Members
  • Posts

    680
  • Joined

  • Last visited

  • Days Won

    18

Everything posted by Jan Romero

  1. I don’t have a custom example, but it’s always a good idea to check out the source code of the module itself. You’ll find the render() and processInput() functions particularly interesting. In the end though, you can pretty much do anything you want, as long as the name-attributes of your inputs match the ones processInput() expects. So if you want more control than the options array gives you, you may just write static mark up into your template file, or you may put in the effort and take the fieldtype’s configurable settings into account, depending on your needs.
  2. To be fair, the module is called Emo.
  3. https://processwire.com/blog/posts/processwire-2.5.7-core-updates/#field-template-context-now-available-for-any-field-property Sounds like this is being taken care of already
  4. Because you want a user to see a menu item if they have one or more, i. e. any of that item’s roles, you want to break out of your foreach as soon as the first matching role is found. Otherwise, any missing role will set $menuVis to false. That would be a good idea if you wanted a user to require all of the item’s roles, in which case you would have to break out of the loop at the first missing role, lest any further iteration sets $menuVis to true again. if($child->menu_roles->count()) { $menuVis = false; //Assume false in case the foreach doesn't find any matching roles and sets it true foreach($child->menu_roles as $cmr) { $cmrRole = wire('roles')->get("$cmr->name"); if (wire("user")->hasRole("$cmrRole")) { $menuVis = true; //has this role, so no need to check more roles break; } } } if($menuVis == false) continue;
  5. Doesn’t seem to happen for me. I’m also using the start and limit parameters and sorting by an integer field. This might have something to do with your DB configuration and thus not affect all PW sites equally. Perhaps posting your full selector string can shed some light on this, although I doubt anything short of using sort=random as a second parameter can explain this In any case, if you sort by something you expect to tie frequently, it’s definitely bad practice to not specify a second field. Databases do all kinds of magic and usually can’t guarantee tables to be read in a reliable order. For perfect consistency (pages can have identical titles as well), best sort by ID, which must be unique anyway.
  6. Be aware this makes the page visible for guests as well. I’m not actually sure if what you’re looking for is possible in PW out of the box.
  7. You could write a bunch of PHP using the ProcessWire-API into a template file and then just call it once. Or you could do it on the database with one line of SQL. ProcessWire’s tables are very clean and easy to understand. If you have access to PhpMyAdmin, I’d recommend doing it that way. It will be something like insert into field_mynewcheckbox (page_id, value) select page_id, value from field_myoldcheckbox (Treat this as pseudo code) edit: I should mention this basically clones all values of this field, which is okay in this case, since a checkbox only has 2 states. This is also assuming that you’re using the two checkboxes on all the same templates etc. Otherwise you may want to filter the Select a bit, or just use Craig’s code below.
  8. If you’re able to take a little time to learn basic HTML and PHP, I think ProcessWire will be a great choice for you. It is very beginner friendly in that sense. However, if you want to pick a ready made template and only add your own content, you will find the wealth of options much greater with other systems.There are so called site profiles for ProcessWire, which provide you with a ready-to-go starting point for your site. You can choose one during the installation. They’re a great resource for learning how to work with ProcessWire. Just open one of the template files and have a look. The thing is that HTML/CSS and PHP are entirely independent of ProcessWire, which is why you probably won’t find tutorials that teach you both at the same time. Your best bet will be to learn at least basic HTML and CSS from an independent resource (there are plenty in every possible format and medium). I wouldn’t bother with PHP and webservers just yet. In fact you can probably take your first PHP steps directly with ProcessWire. But HTML is pretty much a requirement first. After all, you will use PHP to generate HTML code. Just don’t be scared and start simple. Create a text file on your local computer and start copying some HTML tutorials.
  9. Sounds like you just need a couple of forms on your frontend. Maybe have a look at FormBuilder? How much experience do you have with HTML forms and ProcessWire’s API?
  10. I’m not fully certain what you are trying to do exactly. Have you seen this thread about deleting orphaned image files?
  11. Try changing it to: $b = "<img src='".$language->bandeira->url."' alt='"$language->title."' />"; You may have to use bandeira->first()->url, if your image field allows multiple images.
  12. Since users are already simply pages under Admin->Access->Users, you probably won’t need to create separate profile pages. You can simply add more fields to the user template. All fields you add there will also apppear in the module configuration of the core module “User Profile”, where you can select those you want individual users to modify themselves. If you still want to use separate pages, you can bind them to users by adding a page-field to the user template. Hope this helps.
  13. Can you show the code you use to make the AJAX call? To access PW you will want to create a page that uses a template in which the ajax request is handled. The request is sent to said page (perhaps /ajax/ or something), not just to the template file. edit: I missed that $input→post returns a WireInputData, so ProcessWire seems to be there. It’s probably still something to do with the request, although I don’t know Angular. Surely it’s not a GET?
  14. Well, as you can tell from the warnings, it seems like PHP’s safe mode is preventing the HTMLPurifier from accessing the file system. More info on Safe Mode: http://php.net/manual/en/ini.sect.safe-mode.php Since you haven’t changed anything, you should probably talk to your hosting provider about this. Maybe they changed the PHP settings? Seems odd that they would enable safe mode, since the docs already call it deprecated and “architecturally incorrect”. http://php.net/manual/en/features.safe-mode.php
  15. You could redirect the images to a php file that decides which version to serve. That way you can serve the same cached version of the page to everyone, but when the browser requests the image file, the login check is performed. However, are the images really the only difference between signed-in users and guests?
  16. I assumed $feature to be the variable from the foreach you posted above. I don’t know the blog module you’re using, though. Do you know the PHP syntax at work in that line? The curly braces are optional for readability. As you probably know, a $-sign indicates a variable. In the case of $feature, it holds one of your categories. So for each of the categories you fetched, it finds 2 pages with that category. Categories are not a “built-in” feature of ProcessWire. The selector I posted assumes your pages have a page-reference field called “category”.
  17. Excellent question. I’ve been having this problem as well. So far I haven’t found a better way than disrupting markdown with zero-width non-breaking spaces, e.g. ***⁠*This is bold****. Edit: note how I was going to use a zero-width non-breaking space inside the entity above to keep that from rendering, but decided against it so you could just copy it. So be aware if you use this method, your users won’t be able to copy your example code from your field description and try it out in the field.
  18. Well you seem to have pretty much formulated the selector you want already You can get the most recent entries by using the built-in “created” field. And because you want the creation dates in descending order, you prefix that with a hyphen: sort=-created, limit=2. Like you said, you can repeat this selector 3 times, or maybe you want to foreach over the categories you have already fetched, for a more dynamic approach. In your example: category={$feature}. $pages->find("template=post, category={$feature}, sort=-created, limit=2";Or if the posts are children of their categories, you may want to do it even more simply: $feature->children("template=post, sort=-created, limit=2";If you have more questions on selector strings, have a look at the docs: http://processwire.com/api/selectors/
  19. I’d say give the current dev version a whirl and update when 2.5 is released. Check out the dev branch thread in the announcements forum. A bunch of people are already running dev on production sites, as it seems. https://github.com/ryancramerdesign/ProcessWire/tree/dev https://processwire.com/talk/topic/3768-processwire-dev-branch/page-13 edit: eh, beaten. Copy and paste is a bit tedious on mobile
  20. You should really think about keeping the markup constant and only changing the CSS. Preferably you would toggle a single class on your container (a <ul> probably) via JS and save the preference to $session through AJAX. Of course, I don’t know your requirements, but all this seems really complex. Even if you really do need to change all the markup (do you want to display different data or do you want to display the same data differently?), you might want to build it entirely in JQuery using AJAJ data or something.
  21. It depends on what you have. If you have the specialty as a string, you can select for the page’s title field like so: $pages->find('template=physician, specialty.title={$search}'); If you know the specialty’s page-id or path, that should work as well. For example on a specialty page, you would want to list all physicians that have that specialty: $pages->find('template=physician, specialty={$page->id}');
  22. You can create a template called something like “category” and use that to predefine your tags. Then you use a page field to select from those. You can find pages that reference a specific page via a page field by using a selector such as $pages->find("categories=$page"); If you put this line in your category-template for example, you would get all pages that reference that category in their page field called “categories”. Alternatively, you can use a simple text field for tags, then split that up into an array of individual tags and link each to a search page that selects pages by doing a full-text search on the same field.
  23. For anyone curious, Nico is referring to this thread. It’s a good read.
  24. Thanks for the reply! I don’t know exactly what the problem was, but I think I got it running. I var_dumped through modules.php until I found the place and the module that were causing the problem. Thankfully it was only the fourth or fifth module (LanguageSupportPageNames). The point where it broke was if($module instanceof Module) in getModuleInfo(), so I added a condition that called getModuleInfoExternal() specifically for LanguageSupportPageNames. With that, PW ran fine and built the module cache. Now I’m running the unmodified wire folder without any problems. I’m guessing it was something I caused, though I’m not sure how. My PHP version is 5.3.28. The upgrade is great, by the way. I’m acting very ungrateful here. Really, I couldn’t be happier with ProcessWire
  25. Not sure if I should make a new topic for this, but yesterday I tried to install the latest dev branch on a site and broke it completely. No errors, no HTTP status, just the my browser’s “connection reset” page. I tried different versions and found this to be the earliest non-working commit. I noticed System Update 7 didn’t run, but changing the DB manually didn’t help. I’m also running a different site on the same server configuration, which accepts the upgrade just fine. It seems to be something to do with the 3rd-party modules I didn’t uninstall. It’s a multi-language site with the Textareas profield. Any pointers would be greatly appreciated!
×
×
  • Create New...