Jump to content

Soma

Moderators
  • Posts

    6,798
  • Joined

  • Last visited

  • Days Won

    158

Everything posted by Soma

  1. renobird, I think what you would want to do is just simply delete the image first (if there's one) and add new one. you should be able to do something like this, though you would have to try out. if(count($user->image)) $user->image->delete(); ... Edit: ...ok maybe not exactly, but looking at api i'll try a moment... Edit: Ok this works: if(count($user->image)) { // if already 1 image $img = $user->image->first(); // get img $user->image->delete($img); // delete it $user->save(); // save user page $user->image = $config->paths->root . "P1000774.jpg"; // add new image $user->save(); // save again } else { // if no image yet just add one $user->image = $config->paths->root . "P1000774.jpg"; $user->save(); }
  2. I'm running plain latest version. With Translation installed. I just pulled latest from today. Still I get the Notices. If I set the $user->of(TRUE), every following echo $page->something throws Notice. Are you sure you can't reproduce this? Make sure you aren't in a god mode or something.
  3. I think I slowly gettin the problem you're running into with this approach. How you're assuming the page field on the "Categories" is named? It works only if you name them always the same as the page that holds the field selected in "instances". So you chose the strtolower($fo->title) to be the field name for the inner foreach, the last one. Instead you would require to do another page select on the "Categories" page to define what the field is called on itself. But I wouldn't want to go as far. Also you added the $fo to the $fielddata before the last foreach, that's why it got prepended. So you add it and at the same time you say you don't want it to be added. Or I'm missing something? Also you could (assuming they're always pages to return) make $fielddata a PageArray and store (import) the pages in there to return. That also kinda shows you're not really returning fielddata but page objects. I'm still not sure about this approach, if there's an easier way or should be done differently.
  4. then how about like this? function Pagefields(Page $page){ $fielddata = new PageArray(); foreach($page->uses as $p){ foreach($page->get($p->name) as $fo){ if(count($fo->get($fo->name))){ foreach($fo->get($fo->name) as $f1){ $fielddata->import($f1); } } } } return $fielddata; } foreach(Pagefields($page) as $p){ echo "<p>$p->title</p>"; } .... edited code a little.
  5. And if you do? if(count($page->instances)){ foreach($page->instances as $instance) { foreach($instance->categories as $cat){ echo $cat->title; } } } else if($page->instances->categories){ foreach($page->instances->categories as $cat) { echo $cat->title; } } else { echo "no instances"; } *** Edited code
  6. Ah ok, now when I solely put this into basic-page: $user->of(true); It throws again the two errors. it gets worse the more special echo code comes later. Edit: sorry, yes they're notices not errors
  7. it's trowing the error in between $user->of(true); echo $user->get("image")->url; $user->of(false); when i remove the echo error is gone.
  8. Ryan, now when testing with $user->of(true); I get this error: Notice: Undefined property: User::$language in /Applications/XAMPP/xamppfiles/htdocs/pw-dev/wire/modules/LanguageSupport/LanguageSupportFields.module on line 125 Edit: and this Notice: Trying to get property of non-object in /Applications/XAMPP/xamppfiles/htdocs/pw-dev/wire/modules/LanguageSupport/LanguageSupportFields.module on line 126 Edit: it's in front end template basic-page.
  9. Ok now if I populate the image field on the admin user I found it would work with both. I tested with normal pages and it isn't the same behaviour. I think this has to do with the user pages. Thanks for posting.
  10. It returns the file url (folder) when the field isn't populated. try: if($user->image){ echo $user->image->url; } That would be? You get the image url? So the field is populated? Really weird can't reproduce. :/
  11. This was the one you got the error: ## Warning: Invalid argument supplied for foreach() in line 2 foreach($p->categories as $cat){} But does this code work or not? foreach($page->instances->categories as $car) { echo $cat->title; }
  12. And what does it do if you do a foreach over the array? How many items are there in the array, just the one image? Make sure you really are using the right field etc. I can't reproduce this.
  13. I can reproduce this. With an editor user with permission to create,edit, add children pages (on all templates), he can't create pages using the "+ Create new" below the ASMselect. Although he can add pages in the same place using the page tree.
  14. Ah ok. And why do you want to change the field names? Anyway interesting, though something I wouldn't do, but don't care about me Still trying to wrap my mind around it. I think since you name it "Select Instance" it must be single page select field type? So there would be no foreach possibly for field "instances". That why the hard coded doesn't work. foreach($page->instances->categories as $car) { echo $cat->title; } Only multiple page select field will return page array of the selected pages even if there's only 1 selected.
  15. Try to this. It will output the categories titles from the pages you selected under instances. foreach($page->instances as $inst) { foreach($inst->categories as $cat) echo $cat->title; } While I don't fully understand what you're trying to do here, I think it looks too complicated. Why are you having a page select "uses" to select what fields are below on the same page? I'm sure it works but think this extra step could be saved. EDIT: Still trying to understand your code. It could be that the foreach $page and again foreach $page is the problem.
  16. Update: So there's a slight problem now with this, in that all language pack maybe missing this translation in case someone uses custom admin theme. THe topnav won't get translated if there's no translation added for /site/templates-admin/default.php. It can be created quickly, but if someone doesn't know the language it's a little difficult and cumbersome. Can we do something about it that will choose the /wire/templates-admin/default.php ? Or urge the language packes creator to have this included?
  17. This is the code I found adding support for markdown links... As I see it's only for links, so no real markdown formatter is used. https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/core/Inputfield.php#L594
  18. Steve, that's not it. This is only for text field output. This is about the field description text, that's shown in the fieldset of the field when editing. Alan, I don't know really, I think Ryan knows better. I was also looking if there's a "field" setting that you could chose which textformatter, but no luck.
  19. alan, you can use markdown or textile syntax in description fields. http://en.wikipedia.org/wiki/Markdown This was mentioned here: http://processwire.c...__fromsearch__1 Markdown is a module in PW by default (textformatter), textile version is also existent. you can, using markdown, simply do this to make links in field description : [linktext](someurl) *** corrected some
  20. Ok I think the answer is easy Uffff it's just that the language pack doesn't really translate the default.php theme template, just the /wire one... so when I create that It should work for the topnav too. And the other texts (edit, view... 404 etc )work because they don't have a domain applied? Is that correct?
  21. No it's done exact same way as default. It includes topnav.inc from itself not wire. I'm even more confused now. Could you download my theme and test? https://github.com/somatonic/teflon-admin-theme-pw2
  22. Thanks ryan, thats useful to know, but why does it work in other installs... and servers. I updated my theme like this, so its working without changing something. Or am i wrong and missing something? *** Ok I think I'm getting old It is the same on my local test server. I'm confused as when I updated my theme with the language translation, it was working. Now it's only the topnav that isn't getting translated, but the other texts (buttons etc) work. Is it because of the inc of the topnav? and the __FILE__ that is there as the domain, and the translation was done on the /wire domain? SO I need to update my theme again. Thanks for the help Ryan.
  23. Awesome Ryan you're a beast! Thanks, I will check it out.
  24. ... maybe some server setting issue. I never got that problem, and this project is on a server I've never used. But definately doesn't work correctly... just the buttons and some texts, but not the topnav. Maybe something to do with the __FILE__ thingies.
  25. Strange really. Yes I checked the language in the user. I defined the default to be german and uploaded german package. After that I created another one just to make sure. But the wierdest is it also doesn't work if I put the "real" admin templates in the site folder.
×
×
  • Create New...