Jump to content

Luis

Members
  • Posts

    295
  • Joined

  • Last visited

  • Days Won

    5

Posts posted by Luis

  1. My little workaround 

    <?php if(!$input->post->import && !$fieldsImport && !$input->post->generate): ?>
    <hr />
    <h4>Separate Fields by comma like this: i,am,a,new,field</h4>
    
    <form name="importform" method="post" action="./">
    <div class="span3">
            <p><label>Field Prefix?</label>
            <input type="text" name="prefix" /></p>
          </div>
          <div class="span3">
            <p><label>Field Tag?</label>
            <input type="text" name="fieldtag" /></p>
          </div>
          <div class="span3">
            <p><label>assign to </label>
            <select name="template">
              <option></option>
            <?php foreach($templates as $singleTemplate): ?>
              <option value="<?php echo $singleTemplate->name ?>"><?php echo $singleTemplate->name ?></option>
              <?php endforeach ?>
            </select>
            </p>
          </div>
      <div class="span12"><textarea name="string"><?php echo $input->post->string ?></textarea><p><input type="submit" name="import" value="import" /></p></div>
    
    </form>
    <?php endif ?>
    
    
    <?php
    
        if($input->post->import){
          $fieldsImport = $input->post->string;
          $fieldsImport = explode(',', $fieldsImport);
        }
      if($fieldsImport): ?>
        <hr />
        <form name="fieldform" method="post" action="./">
    
          <div class="row"><div class="span12"><hr /></div></div>
          <ul>
              <?php foreach($fieldsImport as $fieldNew): ?>
          <?php
          $alleTypes = '<select class="required" name="'.$fieldNew.'">
                <option selected="selected" value=""/>
                <option value="Checkbox">Checkbox</option>
                <option value="Email">Email</option>
                <option value="File">File</option>
                <option value="Image">Image</option>
                <option value="Page">Page</option>
                <option value="Text">Text</option>
                <option value="Textarea">Textarea</option>
                <option value="URL">URL</option>
              </select>';
    ?>
    
            <li><?php echo $fieldNew ?> <?php echo $alleTypes ?></li>
    
          <?php endforeach ?>
          </ul>
          <input type="hidden" value="<?php echo $input->post->prefix ?>" name="prefix" />
          <input type="hidden" value="<?php echo $input->post->template ?>" name="template" />
          <input type="hidden" value="<?php echo $input->post->fieldtag ?>" name="tag" />
          <input type="submit" name="generate" value="generate" />
        </form>
        <?php endif ?>
    <?php
    
        if($input->post->generate){
        
          $prefix = $input->post->prefix;
          $tags = $input->post->tag;
          $template = $input->post->template;      
          
          $addedFields = $fieldgroups->get('name='.$template);  
        
          foreach($input->post as $key => $val){
            if($key != 'prefix' && $key != 'tag' && $key != 'generate' && $key != 'template'){
              $f = new Field;
              if($prefix){$f->name = $prefix.'_'.$key;}else{$f->name = $key;}
              $f->type = $val;
              $f->save();
              $f->tags = '-'.$tags;
              $f->save();
              $addedFields->add($f);
              $addedFields->save();
              echo "$key = $val <br />";
            }
          } 
        }
    
    ?>
    
    
    • Like 4
  2. Note:

    The closing tag of a PHP block at the end of a file is optional, and in some cases omitting it is helpful when using include or require, so unwanted whitespace will not occur at the end of files, and you will still be able to add headers to the response later. It is also handy if you use output buffering, and would not like to see added unwanted whitespace at the end of the parts generated by the included files.

    From: http://php.net/manual/en/language.basic-syntax.instruction-separation.php

    • Like 5
  3. ok, a little sum up. 

    To understand what happens, here is the setup:

    Page called Clients, container for every client. 

    every client got his unique number written to the title.

    The client template itself contains a set of round about 35 fields. 

    I imported a set of data via CSV import Module.

    This set is provided by a client of mine who needs a new Intranet Solution.

    His client Database contains exactly 15987 entries.

    Every entry is one client and so every client is a page. 

    post-782-0-56020400-1366202310_thumb.png 

    As you can see in the screenshot, PW provides a automatic pagination. 

    To handle this amount of data pagination is definitly not the best way. 

    To edit and manage some clients you could use the built in search engine in the backend. 

    Maybe I want to edit clients with the name Richard. 

    I just pick my Clients Name field, type Richard in the Search box, et voila. 

    post-782-0-91898300-1366202643_thumb.png

    What also could be interesting, is the performance of PW. 

    Lets have a look:

    <? $pages->find('template=kunde'); ?>
    

    All clients in one PageArray gives me the following : Page generated in 33.5099 seconds.

    <? $pages->find('template=kunde,limit=50'); ?>
    

    Results in : Page generated in 0.0376 seconds.

    Rendering those sets of data doesnt affect our render time much.  The following:

    <? foreach($pages->find('template=kunde,limit=50') as $client): ?>
      <p>Number: <?= $client->title  ?></p>
    <? endforeach ?>
    

    Results in: Page generated in 0.0462 seconds.

    Conclusion: 

    At a certain point you dont have to worry about how to order pages, instead you have to worry about how to catch your pageArrays as efficient as possible. 

    Managing large amounts of data is somewhat to think about at the very beginning. 

    I´m handling the clients in a tree like this: Home/Database/Clients/

    Hope this was helpful

    • Like 5
  4. To add various events on the same day via Processwire and stored pages we have to edit our existing getEvents() function and we have to change the way we store events. 

    According to my first example we stored events like this: 

    Children of /calendar/ with date and event entry as our single calendar event. 

    Now we change this way a little bit. 

    We create calendar events by date and add children to this day. 

    Something like this: 

    /calendar/01-01-1970/deployunix6/

    /calendar/ -> is our events container

    /01-01-1970/ -> is our day container

    /deployunix6/ -> one event at the 01-01-1970

    This way we could avoid redundant information in our pagetree and easily maintain our calendar. 

    In the next step we edit our getEvents() function. 

    function getEvents(){
    
    	$days = wire('pages')->get("/calendar/")->children("sort=title");
    	
    	foreach ($days as $day)
    	{
    		echo "'$day->title' : '";
    		$events = $day->children("sort=created");
    		foreach ($events as $event)
    		{
    			echo "<span><p>$event->title</p></span>";	
    		}
    		echo "', \n";
    	}
    }
    
    • Like 1
  5. Ryan, 

    i'm setting up a blog for my wifey and mh she is always a little bit like indiana jones and explores all given functions. 

    So I tried to setup a module to just provide the tree of posts and a button "Add new Post". 

    I struggle a bit with the asmselect now to rebuild the new post page, so is there an easier way to achieve this, other than rebuild the whole "new page" page?

  6. thanks for your responses :)

    @photoman355 :

    The intention why I choose TinyMCE is pretty simple, the user knows tiny from the backend, so he might feel comfortable to tiny. 

    I didn't faced any problems with integration so far, just finished the jquery thingy to add the needed divs, a's etc...

    Just tried to keep it on a very simple and basic approach, just click on the $page->body content and change the text on the fly, not more. For further editing you still have to go to the backend. 

    Further editing just feels wrong on the frontend. 

×
×
  • Create New...