Jump to content

thetuningspoon

Members
  • Posts

    691
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by thetuningspoon

  1. I know, but I thought Ryan had somehow configured it to use the more generic icon- instead. Anyway, I had tried fa-file and that doesn't work either... Edit: Double-checked and it still doesn't work.
  2. Oops, sorry... don't know how I missed that. Being able to click the link to edit the field settings would be great, although I would still say it's very helpful as it is for those times you forget field names. I most often have need of this feature when I'm programming my templates and need the name to output the field-- not so much when I need to edit field settings.
  3. I've been trying to use the built in FontAwesome icons in my recent 2.4.0 upgrade and they're not showing in the page list. In the "List of fields to display in page list" under the template settings I am putting "icon-file title" to try and show a page icon in the page list next to the title, but it's not working. Could there be something missing from my upgrade, or is this a known issue that was resolved?
  4. Yeah, they only show when you're in debug mode. I found this feature very useful. What would you change about it, Soma?
  5. Hmm, how do I pre-populate the inputfield with the current image? What would be the equivalent of "value" for a file/image inputfield?
  6. Ok, I figured it out by studying the difference between the html output of my form and the output in the admin backend. I had to separate out the id+name part and give it a special id: $field->attr('name','profile_image'); $field->attr('id','Inputfield_profile_image'); There was more to getting this to work than just that. I had to copy & make a change to InputFieldFile.js, remove that from the $config->scripts array and re-add my own version so that it would appear in the right order, and add the <p> tag and hidden field with the target page number mentioned here: http://processwire.com/talk/topic/2867-small-change-to-inputfieldfilejs-to-facilitate-front-end-html5-uploads/ All in all, if there's any way you can achieve what you're trying to do either with the existing admin (loading it into a FancyBox like Soma has described) or by just building your own form from scratch, it's probably the better way to go. Getting the file/image fields to work on the front end is a royal pain. Edit: Soma, this was for updating an existing page (user page, actually) with an image field already on it. The image was uploading to the page's directory under assets just fine, but would not appear when called on the front end for final output to the end user (the field was showing empty in the database).
  7. $field = $modules->get("InputfieldImage"); $field->label = "Profile Image"; $field->attr('id+name','profile_image'); $field->required = 0; $field->maxFiles = 1; $field->descriptionRows = 0; $field->maxWidth = 800; $field->maxHeight = 800; $field->extensions = 'gif jpg jpeg png'; $form->append($field); I'm able to upload an image and see it appear in the correct directory using the above code to generate an image field. But once it's there, I can't output the image on the site. It's like it's only being associated with the page but not the field. Am I missing something?
  8. Thanks teppo. I had tried remove() before but I was apparently doing it too early in the code.
  9. Is there a good way of removing a script that PW has attached to the $config->scripts array? I am using the admin functions to build a front end form and am struggling with replicating the image/file upload. I finally decided that the best solution at this point would be to just remove all js functionality from that field, but it is including the script automatically when the form is built.
  10. See my last post for the selector I'm using. It is for the site search. PW 2.4. So it is using Ryan's default search.php template with some modifications. I am also doing a similar selector for other pages in which I am just getting the children of the page, and there checkbox=0 works fine. The only thing I can think of is that I'm using the %= on the earlier part of the selector for the more thorough search functionality, but I don't know how or why that might effect the checkbox=0 part...
  11. I don't see why not. But I can tell you that it works....
  12. What do you mean? It is in the docs. checkbox!=1 returned nothing and checkbox=0 worked in some cases but not others. As soon as I replaced it with !checkbox=1 (nothing else was changed in the selector or elsewhere) it worked in all cases. checkbox= seems to behave the same as checkbox=0. This is with PW 2.4. I am using this in the selector for my global site search to not return results from pages which have the checkbox checked. This is what the selector looks like: $matches = $pages->find("body|sidebar|field|another_field%=$q, limit=50, !checkbox=1");
  13. I had this same question. For some reason I can't determine, checkbox=0 would work in some instances but not others. The solution I found that worked in all instances was !checkbox=1. This returns all pages where the checkbox is either unchecked or it doesn't exist at all.
  14. We're working on building a front end login form and the programmer I'm working with discovered that after the form is submitted and the post values are used to log the user in with $session->login(), $user->isLoggedin() still returns false until after the page is physically reloaded, changed, or $session->redirect() is used in the code. Maybe it's just late and I'm not thinking straight, but what is the reason for this?
  15. Thanks! Good point. I removed that line from the code altogether.
  16. Well, I'm no pro at this and you could probably improve it, but here's my attempt which serves my current needs pretty well: /** * Creates a repeater field with associated fieldgroup, template, and page * * @param string $repeaterName The name of your repeater field * @param string $repeaterFields List of field names to add to the repeater, separated by spaces * @param string $repeaterLabel The label for your repeater * @param string $repeaterTags Tags for the repeater field * @return Returns the new Repeater field * */ public function createRepeater($repeaterName,$repeaterFields,$repeaterLabel,$repeaterTags) { $fieldsArray = explode(' ',$repeaterFields); $f = new Field(); $f->type = $this->modules->get("FieldtypeRepeater"); $f->name = $repeaterName; $f->label = $repeaterLabel; $f->tags = $repeaterTags; $f->repeaterReadyItems = 3; //Create fieldgroup $repeaterFg = new Fieldgroup(); $repeaterFg->name = "repeater_$repeaterName"; //Add fields to fieldgroup foreach($fieldsArray as $field) { $repeaterFg->append($this->fields->get($field)); } $repeaterFg->save(); //Create template $repeaterT = new Template(); $repeaterT->name = "repeater_$repeaterName"; $repeaterT->flags = 8; $repeaterT->noChildren = 1; $repeaterT->noParents = 1; $repeaterT->noGlobal = 1; $repeaterT->slashUrls = 1; $repeaterT->fieldgroup = $repeaterFg; $repeaterT->save(); //Setup page for the repeater - Very important $repeaterPage = "for-field-{$f->id}"; $f->parent_id = $this->pages->get("name=$repeaterPage")->id; $f->template_id = $repeaterT->id; $f->repeaterReadyItems = 3; //Now, add the fields directly to the repeater field foreach($fieldsArray as $field) { $f->repeaterFields = $this->fields->get($field); } $f->save(); return $f; } And here's an example of calling it: $f = $this->createRepeater("sc_promos","sc_promo_active sc_promo_code sc_promo_discount","Promotional Offer","shoppingCart"); You can then use $f to add your new repeater field to a fieldgroup/template.
  17. Maybe we could put together a function that would take the repeater name and desired fields as inputs and do all the hard work of creating the fieldgroup, template, and page... If I get a few extra minutes I may give that a try.
  18. YESYESYESYESYES!!!! That was it! I thought that that particular bit of code wasn't necessary because I only wanted to create the repeater and not any associated pages. I'm not sure why it works but it does Yes, I've had to go in and manually hack the database due to errors along the way, but all is working well, so I don't think I've messed up anything too bad I do have to say... this is way complicated for ProcessWire since most things in PW tend to be surprisingly easy. But I don't think Ryan foresaw repeaters being created this way. I'm sure this is something that could be simplified in the future.
  19. Adrian, I just found your post here: http://processwire.com/talk/topic/4736-add-inputfieldrepeater-to-module-configuration-page/ I tried replicating your process for setting up the fieldgroup, field, and template, but PW keeps creating a filedgroup & template with a different name (adding a 1 to the end of it) instead of using the one I created. EDIT: Here is my code: $repeaterName = "sc_promos"; $f = new Field(); $f->type = $this->modules->get("FieldtypeRepeater"); $f->name = $repeaterName; $repeaterFg = new Fieldgroup(); $repeaterFg->name = "repeater_$repeaterName"; //Add fields to fieldgroup - add others as necessary $repeaterFg->append($this->fields->get("sc_promo_active")); $repeaterFg->save(); $repeaterT = new Template(); $repeaterT->name = "repeater_$repeaterName"; $repeaterT->flags = 8; $repeaterT->noChildren = 1; $repeaterT->noParents = 1; $repeaterT->noGlobal = 1; $repeaterT->slashUrls = 1; $repeaterT->fieldgroup = $repeaterFg; $repeaterT->save(); //Now, add the fields directly to the repeater $f->repeaterFields = $this->fields->get("sc_promo_active"); $f->save(); //Add the sc_promos repeater field to the sc-promo-codes fieldgroup $fg->add($f); $fg->save();
  20. Thanks adrian, but I'm having trouble following along with what's happening in your code. I discovered that the system is automatically creating a system template/fieldgroup for the repeater with the repeater_xxx naming convention, but it's not created until after I've gone into the admin and gone in to edit the repeater field. So I tried grabbing the fieldgroup after creating the field in the code and adding to it right away, but it seems that the fieldgroup doesn't actually exist yet? So yeah, I think I'm going to need a simpler answer
  21. Hi! I have been struggling with this for the last few hours and could not find a solution for it anywhere on the forums. I want to create a repeater field using the API and then add fields to it programatically. I can create the field and assign it to a template alright, but I can't assign any fields to the repeater itself. I've tried using $field->repeaterFields when creating the field but cannot figure out what it's supposed to accept. I tried passing it an array of IDs as well as a fieldgroup, but I couldn't get either to work. Any ideas?
×
×
  • Create New...