Jump to content

Soma

Moderators
  • Posts

    6,808
  • Joined

  • Last visited

  • Days Won

    159

Everything posted by Soma

  1. welcome to the forums yellowled. yes everything is threated as pages. I don't think certain types stored as xml or json will not make it more performant than mysql, rather opposite. If a page exists only to store informations that the can be pulled form anywhere is a good way. It doesn't even need to have a ".php" template attached if that's page never going to be viewed anyway. You can of course have data as pages that will get displayed through other pages. One way to display it is using code in the page template that will render the data, so in the foreach you have something like a markup generating code. FOr example often used is something like this. if(count($page->children('template=member'))){ foreach($page->children('template=member') as $m){ echo "<div class='box'>"; echo "<div class='image'>"; echo "<img src='{$m->image->size(200,0)->url}'/>"; echo "</div>"; echo "<div class='text'>"; echo "<h2>{$m->title}</h2>"; echo "<h3>{$m->member_function}</h3>"; echo $m->member_descr; echo "</div>"; echo "</div>"; } } Or other ways of doing it, as you like. Another possibility would be to have a member.php that will contain the markup and then can be rendered using the $page->render(); in the member.php: <div class='box'> <div class='image'> <img src='<?php echo $page->image->size(200,0)->url ?>'/> </div> <div class='text'> <h2><?php echo $page->title ?></h2> <h3><?php echo $page->member_function ?></h3> <?php echo $page->member_descr ?> </div> </div> then the previous would be like this: if(count($page->children('template=member'))){ foreach($page->children('template=member') as $m){ $m->render(); } } There's not "right" way, just what you like most and would make sense in your situation. There many many ways to build it. EDIT: corrected some code...
  2. Soma

    joaovieirasantos

    ... and I thought you were really that bad!
  3. This is just the data table of the field. field_x table. The fields table holds the information (title etc) of the field and has flags column. If the field is not attached to any template there will be no relation entry in the fieldgroups_fields. So you could next go to the fields table and delete the field you want to delete. Then the data table of the field itself (field_xxx).
  4. What "flags" do they have that don't show in the admin field list? Are they used in any fieldgroup? You can delete them manually, in the tables fieldgroup_fields first (look for id) and fields table, then the table of the field itself field_x. Edit: Though I also after excessive coding, trying got this issue ones, I delete the table and it's references manually. BUt maybe would be good to know what the problem could be that this happens.
  5. NO it's not Most likely it's due to some excessive trying... If you delete a field the table will get deleted too.
  6. Could it be that the field is system thus not visible by default. Try setting the filter to show system fields too.
  7. I think this implementation is working well. Anyone? Since Ryan has done some recent changes to the inputfieldTinyMCE and added Codemagic to the core TinyMCE folder, we'll have to first sort this out. I told Ryan it may be best to put Codemagic not in core, since it will be hard to add translation to it this way. I haven't tested yet if the translation of Third-Party plugin would work with my method here of adding it externally via the field configuration. But this way one could add the necessary [lang].js to it. Anyway anybody interested in helping out testing/doing?
  8. Hey 12345j, are you still here? I just tried this out and fixed a bug with "$config" should be $this->config in modules. Mind if I put this on my github account? Edit: I just added a configuration setting, for defining the html tag the js script will get prepended to. Right now it will be prepended to the </head>, which might not where one wants to have it. So I added a text field where you can for example use "</body>" instead. Edit: Ok I just went and created a git repo with the updated version of this module. I also renamed the module to EmailObfuscator: https://github.com/s...EmailObfuscator
  9. You could try something like this: function Pagefields(Page $page){ $fielddata = new PageArray(); foreach($page->uses as $p){ foreach($page->get($p->name) as $fo){ if($fo->get($fo->name) && count($fo->get($fo->name))){ foreach($fo->get($fo->name) as $f1){ $fielddata->import($f1); } } else { $fielddata->import($fo); } } } return $fielddata; } foreach(Pagefields($page) as $p){ echo "<p>$p->title</p>"; }
  10. I tried and can confirm. Ryan? Adding a tabfield right after the 2 floated fields it breaks.
  11. 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(); }
  12. 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.
  13. 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.
  14. 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.
  15. 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
  16. 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
  17. 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.
  18. 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.
  19. 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.
  20. 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. :/
  21. 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; }
  22. 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.
  23. 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.
  24. 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.
  25. 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.
×
×
  • Create New...