Jump to content

maxf5

Members
  • Posts

    143
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by maxf5

  1. It's been a while and i share my first results:

    1) Make some pages with FieldtypeMapMarker
    2) Build a form with an input for the Zipcode/PLZ and a select for the radius.
    3)  upload the .tab file in your template (german zipcodes)

    tomorrow i will make the styling and getting the distance between plz and results and render the google maps.

    code:

    define("OGDB_LOCAL_DATA_FILE","./PLZ.tab");
    
    function plztolatlong($plz) {
    	$fileData = @file_get_contents(OGDB_LOCAL_DATA_FILE);
    	if ( $fileData == FALSE ) {
    		die("ABBRUCH: konnte Daten nicht laden (".OGDB_LOCAL_DATA_FILE.")\n");
    	}
    
    	$fileData = explode("\n",$fileData);
    
    	for ( $i=1; $i < count($fileData); $i++ ) {
    		$fileRow = explode("\t",$fileData[$i]);
    		if ( $plz == $fileRow[1] ) {
    			$origin_lon = $fileRow[2];
    			$origin_lat = $fileRow[3];
    			$city = $fileRow[4];
    		}
    	};
    
    	$out['lat'] = $origin_lat;
    	$out['lon'] = $origin_lon;
    	$out['city'] = $city;
    	return $out;
    }
    
    $distance = $input->post->radius; // Get distance
    $plz = $input->post->plz; // Get PLZ
    
    $getlatlng = plztolatlong($plz); // plz to lat and long
    $lat = $getlatlng['lat']; // just for test reasons later
    $lng = $getlatlng['lon']; // just for test reasons later
    
    echo "<pre>";
    print_r($getlatlng);
    echo "</pre>";
    echo "LAT: " . $lat . "<br />";
    echo "LONG: " . $lng . "<br />";
    
    $radius = 6371;		// earth's radius in km = ~6371
    
    // latitude boundaries
    $maxlat = $lat + rad2deg($distance / $radius);
    $maxlat = str_replace(',', '.', $maxlat); 
    $minlat = $lat - rad2deg($distance / $radius);
    $minlat = str_replace(',', '.', $minlat);
    
    // longitude boundaries (longitude gets smaller when latitude increases)
    $maxlng = $lng + rad2deg($distance / $radius / cos(deg2rad($lat)));
    $maxlng = str_replace(',', '.', $maxlng);
    $minlng = $lng - rad2deg($distance / $radius / cos(deg2rad($lat)));
    $minlng = str_replace(',', '.', $minlng);
    
    $q = "template=filialen, mapfield.lat>=$minlat, mapfield.lat<=$maxlat, mapfield.lng>=$minlng, mapfield.lng<=$maxlng";
    $results = $pages->find($q);
    
    echo "<h2>Ergebnisse</h2>";
    
    foreach($results as $r) {
      echo "<h3>{$r->title}</h3>";
      echo "<p>{$r->mapfield->adress}</p>";
      echo "<p>{$r->filial_tel}</p>";
      echo "<p>{$r->filial_mail}</p>";
      echo "<p>{$r->filial_www}</p>";
    }
    
    echo $ff;

     

    FILES:

    PLZ.tab

     

    • Like 3
  2. I had the same discussions when i joined a new agency and when we started to make a relaunch of one of our sites.
    They all wanted Typo3 or WP, but fortunately i could convince them to use ProcessWire and i was happy as f*ck.

    You save at least 50% of time when building functions with the awesome PW API comparing to other CMS.
    You can use PW for small and large sites, where other CMS would be a total overkill. I experienced that so called big CMS with ~100 Sites have a loading time of > 4 seconds (even with caching, gzip, css + js compression, .. ).
    From one to endless languages or PW Sites with > 100.000 subsites shared in the forum, theres no limit in my opinion.
    After 2 years of developing with PW, it was the best decision of my life switching from Typo3 and WP.
    Just warn your Co-Workers working with PW is addictive and they'll never come back ;) 

    • Like 3
  3. thanks for everything @abdus !
    I merged the database of the crashed one with the backup db. After some trys it worked again : )

    I still don't know how did that happen, added three fields to a template in the backend -> Reno crashed -> Default Admin Theme worked for 5 seconds -> then these errors.
    It was a PW 3.0.71 installation. Well, hope won't happen in future.

    • Like 1
  4. Hey @abdus,

    my files (/wire and /templates) are fine. I duplicated the files on a local xampp with a database clone of the site 1 week ago.
    Then it works fine. If I import the live-version database, i have the same problem.
    So something crashed inside the db.. permissions/page-rights or languages.

  5. Hey,

    i just added some fields to a template. After long loading time suddenly the backend changed from "Reno" to the default admin theme without a cause.
    I went back to the tree view and suddenly all i can see is attached: 


    I worked 2 weeks on the site. Everything was fine.. 

    dev.captiva-power.de-admincaptiva-page-.png

  6. hey guys, try:

    // replace 38 with the id of the user role, here 38 = superuser
    $items = $users->find("roles!=38"); 
    foreach ($items as $i) {
    	// returns guest, superuser excluded
    	echo $i->name; 
    }

    you will find the role-id in the url when you edit Admin > Access > Roles > guest, superuser, login-facebook,...

    • Like 1
  7. Wont something like this work for you?

     

    <?php
    $sections = $pages->get("/page1")->children;
    foreach ($sections as $s) {
      $type = $s->template;
        switch ($type) {
          case "template2":
              $out .=  "<h2>{$s->title}</h2>";
              $out .=  "<p>{$s->text}</p>";
              break;
           case "template3":
              $out .=  "<h2>{$s->title}</h2>";
              $out .=  "<img src='{$s->img}'>";
              break;
          }
    }
    echo $out;
    ?>

     

  8. Hey guys,

    i am planning a "radius search" for branches (in Germany).

    Within a form the user inserts his postal code and choose from one of the distance (20km, 50km, 100km) and gets all the branches in his radius.
    The branches are saved as pages with the fieldtype MapMarker, where you have latitude and longitude.
    http://modules.processwire.com/modules/fieldtype-map-marker/ )

    did somebody did something similar in the past? I am just asking, before i will spend the whole weekend in front of the pc :-[

  9. @szabesz , yes.. some problem with <pw-region>

    in _main.php

    <pw-region id="something">
    ...
    </pw-region>


    in basic-page.php

    <p pw-append="something">
      12123123123
    </p>

    and you get:
    Unbenannt33.PNG.26ad4c103b1394b8055261c048ef5f4d.PNG

    Settings:
    $config->useMarkupRegions = true;
    $config->prependTemplateFile = '_main.php';
    ProcessWire 3.0.69 

    PHP VERSION 7.0.18

     

     

    • Like 1
  10. is there still a bug? Same problem here on Processwire 3.0.69


    $config->useMarkupRegions = true;
    $config->prependTemplateFile = '_main.php';

    in _main.php
     

    <?php namespace ProcessWire; include_once("./_init.php"); ?>
    
    ....
    
    <region id="dummy">
      <h1><?php echo $title; ?></h1>
      <?php echo $teaser; echo $content; ?>
    </region>


    in basic-page.php

    <?php namespace ProcessWire; ?>
    
    <p pw-prepend="dummy">
      123
    </p>

     

    Voila:

    Unbenannt33333333.PNG.fb02cf29cca6dafd8eb0865dee9dd213.PNG

    • Like 1
  11. Holy shit, it works! thank you so much.
    And sorry for the long questions, i shoud have learned other template strategys earlier.

    I will share my codes when its all finished for people who are interested. I built some kind of page/grid-builder with uikit and PageTables.

    Will now look at Page Table Extended.

    • Like 2
  12. Hey @evan, thanks for your time and patience.

    My content-blocks aren't stored as subpage on the particular page. I collect them in an unpublished page (called Views, due to menu reasons).

    Is there a chance to search in the content of the blocks referring to the linked page?

    This will of course return the one unpublished page where all blocks are stored (Views)
     

    <?php
    $q = $sanitizer->text($input->get->q);
    
    $input->whitelist('q', $q);
    $q = $sanitizer->selectorValue($q);
    
    //selector normal content
    $selector = "title|headline|summary~=$q, limit=50";
    
    // selector content blocks
    $views_query = [
      'template=Text|ParallaxBanner', // Template
      'textfield|parallaxtext*="'.$q.'"' // Fields
    ];
    
    if($user->isLoggedin()) $selector .= ", has_parent!=2";
    
    // normal pages
    $matches = $pages->find($selector);
    
    // Find parent pages of content blocks
    $views_results = new PageArray();
    foreach ($pages->find( implode(', ', $views_query) ) as $p) {
      $views_results->add($p->parent);
    }
    
    // Combine results
    $matches->import($views_results);
    ?>

     

  13. I was testing out that solution @evan

    Works pretty well so far. I put the range slider to each template block to set the grid widths for desktop, tablet and mobilephones. Atm working on the output of the grids and cols.

    There are a few question i have in mind.

    1) My website has a search engine, so how you can search in those blocks?

    I think you can just use field.subfield but not field.subfield.subsubfield as selector.

    Like my PageTable field is called views. 

    $selector = "title|views.accordion.textarea";

    $results = $pages->find($selector);

    2) PageTable extended would be kickass, but i am using blank templates without PHP Files. Rendering wont work as far as i read the docs.

×
×
  • Create New...