Jump to content

mr-fan

Members
  • Posts

    848
  • Joined

  • Last visited

  • Days Won

    4

Posts posted by mr-fan

  1. found a solution ....maybe someone yould use it sometimes...

    setup only the right HOST under the config.php nothing else

    /**
     * Installer: HTTP Hosts Whitelist
     *
     */
     
    $config->httpHosts = array('newdomain.com');

    in the htacess i've setup a additonal redirect to the existing force https and redirect www to nonwww for catching all oldomain.com calls to redirect to newdomain.com - all links should be working perfect after that switch under the new domain...the rest is fixing seo mess that comes with domain url chaning 😉

    kind regards mr-fan

      # -----------------------------------------------------------------------------------------------
      # 9. If you only want to allow HTTPS, uncomment the RewriteCond and RewriteRule lines below.
      # -----------------------------------------------------------------------------------------------
      RewriteCond %{HTTPS} off
      RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
     
      RewriteCond %{HTTP_HOST} olddomain.com$ [NC]
      RewriteRule (.*) https://newdomain.com%{REQUEST_URI} [L,R=301]
     
      RewriteCond %{HTTP_HOST} ^www\. [NC]
      RewriteRule (.*) https://newdomain.com%{REQUEST_URI} [L,R=301]
    • Like 1
  2. Hi,

    i've a installation where the client have to change the domainname on a existing installation.

    beside the negative SEO effects how to get it proper done with PW?

    i've set $config->httpHosts and Host to the according domains the PW accept both.

    but all links should only use the new main domainname like:

    https://olddomainname.com    -> redirected to https://newdomainname.com

    how to implement it via htaccess right so that i don't blow it up. Subpages dont change only the hostname?

    RewriteRule ^(.*)$ http://newdomainname.com/$1 [R=301,L]

    isn't working?

    Pagepathhistory and jumplinks are installed to catch 404 or other stuff.

    Kind regards mr-fan

  3. On 9/12/2021 at 8:57 AM, franciccio-ITALIANO said:

    well i wanted to avoid ANY special module, to find a solution with only generic php language, anyway i will use the repeater, still i didn't learn how to use page categories and child pages... 

    knowing page categories and child pages - or the usage of templates and pages as contentcontainers for everthing you ned - is essestiel!!

    this is a great startpoint for learn this very very important thing - processwire manage the content you need - with simple PHP solutions you get get the content in your templates...i created a complete blog logic without a special module or something else - but you have to know to use pages and fields and learn this things.

     

    • Like 2
  4. many ways...

    1. use childpages instead of repeaters would be possible
    2. repeater matrix (pro module)
    3. pagetable module
    4. editing the https://processwire.com/modules/fieldtype-events/     to your needs this is a example for repetable items in a small amount in a own fieldtype module
    ....this comes in the first minute of thinking about your question.
    processwire API code goes the same as for repeaters with different sources of the content (get childpages instead of repeateritems and so on)...

    kind regards mr-fan

    • Like 2
  5. So good evening it's been a while since i've got a real problem that give me headache.

    I've got a site PW 3.0.101 - WireMailSmtp 0.60

    -> setup should work smtp access tested with local emailclient
    -> online test within WireMailSmtp give me success message

    I use just a simple PHP contact form no formbuilder and so on just plain

    wireMail($emailTo, $emailfrom, $betreff, $msg);

    and i dont get it work? Any hints to look at or to test further?
    im not that backend server guy and ;(

    kind regards
    Martin

  6. You could take all files at one hidden place like

    parent ->pdf-files
       child  ->a.pdf
       child ->b.pdf

    and on every page you want you can link via dialog to the files or make a file-inputfield with selector to the setup parent page with all childpages as choice.

    I used at one project a pagetable field to have all files on one place - and can link to them from any other page.

    there is a commercial module, too

    and a free one with less functions but much to learn from

    https://processwire.com/modules/media-library/

    kind regards mr-fan

    • Like 3
  7. Or you can use the free available PageTable module, but it is a bit more setup to use this...

    https://www.mr-erding.de/service/formulare/

    PT field connected with the file templates as childpages - so User can only upload the filetypes you setup with templates.

    With this great tutorial from @Soma you can count downloads, too with this setup equal if you use RP matrix or PageTable.

    https://soma.urlich.ch/posts/flexible-downloads-using-pages/

    kind regards mr-fan

  8. just a short update on this - i am stresstesting the PW way and i'm on the way yust with simple pages for now and see what comes up the road.

    made a crude script to get dummy data and created around 88k pages (DB are now 35MB) in very fast time on shared hosting...just for example to create 48 testrecords for every day (17260 pages - 2 records per hour) the scripts runs on in about 80 seconds...just for others that are search on create dummy content in a quick and dirty way i let my code here (if there are better ways - at least as a bad example..;)

    Spoiler
    
    //create dummy data uncommend first year then month then day then records
    $year = 2015; //setup a non existing year!
    $yearPage = $pages->get("title=$year");
    $yearChilds = $yearPage->numChildren;
    
    //switch for the creation of the pages since a parent have to exist every childround has to start separate
    $cyear = 1; //second create year -1 page
    $cmonths = 0; //third create every month --12 pages
    $cdays = 0; //fourth create 30 days for every month --360 pages
    $crecords = 0; //fifth create records for every day of a year 48 records per day --17260 pages
    
    //first year setup the year
    if ($cyear == 1) {
    	if ($yearPage == "") {
    		$p = new Page(); // create new page object
    		$p->template = 'year'; // set template
    		$p->parent = $pages->get(1049); // parent is wetter
    		$p->name = $year; // give it a name used in the url for the page
    		$p->title = $year; // set page title (not neccessary but recommended)
    		$p->save();
    		echo "<h1>$year created</h1>";
    	}
    } else {
    	echo "<h1>$year is there</h1>";
    }
    
    //create the months of a year if a year has no childpages...
    if ($cmonths == 1) {
    	if ($yearChilds != 12) {
    		$m = 1;
    		while ($m < 13) {
    			$p = new Page(); // create new page object
    			$p->template = 'month'; // set template
    			$p->parent = $yearPage; // set parent
    			$p->name = $m; // give it a name used in the url for the page
    			$p->title = $m; // set page title (not neccessary but recommended)
    			$p->save();
    			echo "$m -ok, ";
    			$m++;
    		}
    	}
    } else {
    	echo "<h1>To create Months switch cmonths to 1</h1>";
    }
    
    if ($cdays == 1) {
    	echo "<h1>Days </h1>";
    	//create the days
    	$months = $yearPage->children;
    	//loop the months and create 30 days every month
    	foreach ($months as $month) {
    		$d = 1;
    		while ($d < 31) {
    			$p = new Page(); // create new page object
    			$p->template = 'day'; // set template
    			$p->parent = $month; // 1set parent
    			$p->name = $d; // give it a name used in the url for the page
    			$p->title = $d; // set page title (not neccessary but recommended)
    			$p->save();
    			echo "$d -ok, ";
    			$d++;
    		}
    	}
    } else {
    	echo "<h1>To create Days switch cdays to 1</h1>";
    }
    
    //create the records of a day
    //some functions needed for the data
    function mt_rand_float($min, $max, $countZero = '0') {
        $countZero = +('1'.$countZero);
        $min = floor($min*$countZero);
        $max = floor($max*$countZero);
        $rand = mt_rand($min, $max) / $countZero;
        return $rand;
    }
    
    if ($crecords == 1) {
    	$months = $yearPage->children;
    	//loop the months 
    	foreach ($months as $month) {
    		//Loop the days
    		$days = $month->children;
    		foreach ($days as $day) {
    			$r = 1;
    			//create 48 records per day so every 30 minutes take a record...
    			while ($r < 49) {
    				$p = new Page(); // create new page object
    				$p->template = 'record'; // set template
    				$p->parent = $day; // 1054 == 2018
    				$p->name = $r; // give it a name used in the url for the page
    				$p->title = $r; // set page title (not neccessary but recommended)
    				//dummy data generation
    				$p->temp = mt_rand_float(-10, 50, '00');
    				$p->hum = mt_rand(20, 90);
    				$p->pres = mt_rand(500, 1500);
    				$p->light = mt_rand(1, 16);
    				$p->rain = mt_rand(0, 60);
    				//save datarecord
    				$p->save();
    				echo "$r -ok, ";
    				$r++;
    			}
    		}
    	}
    }

     

    So far next things are to create a script that runs to build the averages of month, year for long term stats and then i will try how reporting and visualisation in an easy graph - works together with a DB that have around 90000 pages with just some integers and floats.

    I would first try how an easy to use chart library would work (https://gionkunz.github.io/chartist-js/index.html)
    Since this tools all use JSON data i think i could cache or better prepare this JSON strings for the charts and see how fast it performs...i'll report again.

    But this is an interesting experiment so far - i could choose how i spend my freetime in two really different worlds
    ->work on the backend with PW or solder and glue some things together on the hardware parts...before this project i was captured only on the web...;)

    • Like 3
  9. Thanks for all input again.

    Again i was not to clear - single project just for me and just for information no public hits no further usecase for the system.

    55 minutes ago, LostKobrakai said:

    Especially if you plan to hit the latter case I'd also suggest looking at proper databases for time series data, especially if the number of entries is meant to grow beyond the ~500k–1kk mark. I'd look at influxdb or postgresql with timescale plugin.

    Yes LostKobraKai i think i did'nt plan on this one...until now i didn't have such a usecase or wasn't deep into database performace (what is not really needed for normal websites if you use PW as a base...it scale for this cases and i know that well)

    So may i am a little bit to naive on this project - and my feeling said "Hey try to ask the dev guys in the forum for hints" ...;)

    I would first go the hard way and make my hands dirty and will try how far PW could go on this one....

    Yes nested page setup like metioned wont scale on things like "live aggregating" all saved data, but i think i would be happy if i could get things like average of year/month/week and store them in separate fields on the dedicated template - so like netcarver wrote if i am modest in granularity it will run fine.

    But a important Tipp is the FieldtypeEvents module  from Teppo, i forgot this one - it would work great for the week dataset so many pages are spared.

    What i will try with dummy data is now:
    templates /station/year/month/week
    station (id, title)
    year (id, title, temp, humidity, pressure, rain, light) - the average - average from 12 childpages should be no problem
    month (id, title, temp, humidity, pressure, rain, light) - the average  - this will end in 52 childpages for a join for the average
    week (id, title, records - modified eventtype field for the intraday records) - this will end in 672 entries (if i take a record every 15 minute) in one week field

    Problems on this one would be selecting from date to date but i would be fine with averages of weeks or months...and maybe the amount of fieldtypeevent tables (52 per year)?

    I don't have the time to investigate in other DB systems, since this year i've got one more little maid that take over my speartime ?

    But with your interesting input i can think i get in the right direction, and don't have wrong views on aggregation and reporting of the collected data.
    Since alle of you pointed out that the collection wouln't be the problem with PW or MySql....but all the other stuff. And on these points i could make compromise since this is only a hobby project.

    I will report (even if it took a while).

    Even on such rare and offbeat questions in this forum you get helpfull and friendly answers!
    You all made my weekend! - I love this forum, it is a hidden island in the www

    • Like 5
  10. Ok i only thought that the API request would be easier if i could filter with parent pages, then run an SQL trough all pages on the created date field?

    // Find all entries of May 2019
    $records = $pages->get("/2019/05/")->children;

    with my simple DB wisdom i think PW would find the needed data faster...but this is the topic of this post...my lack in DB background (this is the main reason why i like PW so much...;)

    the parent structure would be no problem - i've in my mind that the old blog tutorial from Joss save posts with such a system on page save...

  11. Ok sorry for don't beeing more clear in my first post... ("ESP8266" is a Arduino like Microcontroller that runs the sensors and send via WAN to my website for datastorage)

    like you thought it is one weather station i would like to build up at a minimum collecting temperatur, humidity, pressure, amounth of rainfall and maby a light sensor for sunshine hours per day).

    So my first "PW way of life" would go for pages...

    Data simple send every 10 minutes via POST or GET to a template and save data as pages.

    template "station" as parent holder - maybe i will create a second one at my office...so here we have a title field at least
    template  "record" as child of station for the data records - fields like i wrote 4-6 - temp,humidity,pressure,rain, light - all integer or float fields

    i think i should try with dummy entries if this setup would work...

    For better caching and overview i could adapt a kind of blog page tree like /station/2019/07/20   so i get a parent for year/month/day so filtering and data processing via PW API would get much more performant i think??

    thanks for all input.

  12. I've searched in the forum and found some entries but no one really fits...

    project goal - building a simple weatherstation with an ESP and send the data to my PW page and save it...that sounds easy

    load - would be just 4-6 records like (temp, humidity, pressure, rain, brightness...)

    but if i set the timer to 10 minutes - there will be 52560 records in only one year....and it should run a few years data...

    question - how to save the data - that visualisation (d3 or something else), database performance and so on would work...

    • So could i simple run with a page template for the data and save all records to a page (5 years would be 262800 pages...)?
    • Or should i setup a own mysql table for this one - links or examples would be great - with this i'm not experienced?
    • Or could i go with something like RockDataTables ?

    Where is the right path...i take should i?

  13. Just have to let at least my words here - the last months sadly i don't had much work with PW - but now i was in need of pdf thumbs....and there are two modules....first one doesn't work.

    This one runs for me now on shared host, PHP 7.2 and PW 3.101 and i have to say thank you again to Adrian!

    Even the small not polished modules from you work as a charm over years ?

    Best regards from a atm sparetime PW user.....(two daughters have taken over my time almost complete - best wishes to @Pete )

    mr-fan

    • Like 3
  14. Installed a older site profile into a fresh new PW master version 3.0.123 and get a problem with fieldtype options field.

    Message Process return no content in the backend fieldsetting and pages that use a optionsfield.

    On Frontend with debug mode on i get this:

    ProcessPageEdit: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'mydbname.fieldtype_options' doesn't exist
    
    #0 W:\laragon\www\12_projectname\wire\modules\Fieldtype\FieldtypeOptions\SelectableOptionManager.php(139): PDOStatement->execute()
    #1 W:\laragon\www\12_projectname\wire\modules\Fieldtype\FieldtypeOptions\FieldtypeOptions.module(263): ProcessWire\SelectableOptionManager->getOptions(Object(ProcessWire\Field), Array)
    #2 W:\laragon\www\12_projectname\wire\core\Wire.php(389): ProcessWire\FieldtypeOptions->___wakeupValue(Object(ProcessWire\Page), Object(ProcessWire\Field), Array)
    #3 W:\laragon\www\12_projectname\wire\core\Wire.php(416): ProcessWire\Wire->_callMethod('___wakeupValue', Array)
    #4 W:\laragon\www\12_projectname\wire\core\Page.php(1422): ProcessWire\Wire->_callHookMethod('wakeupValue', Array)
    #5 W:\laragon\www\12_projectname\wire\core\Page.php(1150): ProcessWire\Page->getFieldValue('orientat 

    Field name was orientation and there is the break on the getFieldValue function?
    But in the DB everything is there - are there bigger changes from PW 2.8 to 3.x??
    the used field_orientation table and all the other option fields is there, too...

    what could here gone wrong on db installation of the site profile or incombatibility from PW 2.x to 3.x?

    If there is no fast solution or thing that i've not in mind - How could i setup this Fieldtype new?
    Deinstallation/reinstalltion of this core fieldtype is not easy i think?

    Best regards mr-fan

     

  15. default theme was ok...but uikit should have be changed to the default, but i think there were reasons to separate this things...

    I don't know if i get the time the next two weeks - for every one who wanna try here is my messy start on get the right uikit markup.

    It builds a responsive grid with standard ui cards with header,body and footer.

    The view and edit buttons are on the footer - hover on cards with selection not implemented - like i wrote just playing a little bit and have fun.

    Spoiler
    
    	/**
    	 * Render notes for display on landing page.
    	 *
    	 * @access private
    	 * @return string $out Markup of rendered notes for display.
    	 *
    	 */
    	private function renderNotes($notes) {
    
    		$out = '';
    		$user = $this->wire('user');
    		$urlParamPageNumStr = $this->wire('input')->pageNumStr() ? "?page=" . $this->wire('input')->pageNumStr() : "";
    		$viewIcon = "<i class='fa fa-lg fa-eye'></i>";
    
    		// asterisks @todo: use this?
    		//$priorities = array(1=>"fa-arrow-circle-down",2=>"fa-minus-circle",3=>"fa-arrow-circle-up");
    		//fa-exclamation-triangle  fa-exclamation-circle
    		$priorities = array(1=>"fa fa-arrow-circle-down fa-lg pw-nav-icon fa-fw",2=>"fa fa-minus-circle fa-lg pw-nav-icon fa-fw",3=>"fa fa-arrow-circle-up fa-lg pw-nav-icon fa-fw");
    		//$priorityClasses = array(1=>'dn_low_priority',2=>'dn_normal_priority',3=>'dn_high_priority');
    
    		$out .= "<div class='uk-child-width-1-4@l uk-child-width-1-3@m uk-child-width-1-2@s uk-grid'>";
    
    		// loop through notes, building markup
    		foreach ($notes as $note) {
    
    			// add margin left if required
    			#$classMarginLeft = $i ? " uk-margin-left" : "";
    			// @todo: better presentation of truncated text?
    			// @todo: what about long titles?! truncate?
    			$viewURL = $this->baseURL . "/view/{$note->id}/{$urlParamPageNumStr}";
    			$viewMarkup = "<a href='{$viewURL}'>" . $viewIcon. "</a>";
    
    			## editing rights and markup
    			// users not allowed to edit each other's notes and this user is not the note author
    			$showEditMarkup = $this->checkEdit($note);
    
    			if($showEditMarkup) {
    				$viewEditDividerMarkup = "<span class='dn_note_view_edit_divider'>&#47;</span>";
    				if($note->is(Page::statusLocked)){
    					$editURL = '#';
    					$editIcon = "<i class='fa fa-lock'></i>";
    					$editMarkup = "<a href='{$editURL}'>" . $editIcon . "</a>";
    				}
    				// edit markup: note unlocked and can be edited (@note: including not global restriction on editing each other's notes)
    				else {
    					$editURL = $this->baseURL . "/edit/{$note->id}/{$urlParamPageNumStr}";
    					$editIcon = "<i class='fa fa-lg fa-pencil-square-o'></i>";
    					$editMarkup = "<a href='{$editURL}'>" . $editIcon . "</a>";
    				}
    			}
    			else {
    				$viewEditDividerMarkup = "";
    				$editMarkup = "";
    			}
    
    			##################
    
    
    			// @note: textColour NOT applied to div.dn_note
    			$textColour = $note->textColour ? " style='color:rgba({$note->textColour});'" : '';
    			$backgroundColour = $note->backgroundColour ? "background-color:rgba({$note->backgroundColour});" : '';
    
    			// note width + height + background colour inline CSS styles. applied to div.dn_note
    			$width = "width:{$this->settings->width}px;";
    			$height = "height:{$this->settings->height}px;";
    			$noteWrapperStyles = " style='{$width}{$height}{$backgroundColour}'";
    
    			// we'll use this to do visibility checks and skip if required
    			$limitIDs = $note->limitVisibility > 1 && is_array($note->limitVisibilityIDs) ? implode("|",$note->limitVisibilityIDs) : '';
    
    			// @todo: truncate first?
    
    			// grab the comment text and clean it
    			$text = htmlentities($note->text, ENT_QUOTES, "UTF-8");
    			$text = str_replace("\n\n", "</p><p>", $text);
    			$text = str_replace("\n", "<br />", $text);
    
    			// @todo: revisit this! complete words do not show ...more!
    			$text = $this->wire('sanitizer')->truncate($text, [
    				'type' => 'punctuation',
    				'maxLength' => $this->settings->truncateMax,
    				'visible' => true,
    				'keepFormatTags' => true,
    				'more' => "...<small>(". $this->_('more').")</small>"// @todo?!
    			  ]);
    
    			// meta
    			$date = date($this->dateFormat, $note->created);
    			// @todo; configurable field to get author name?
    			$author = $note->createdUser->name;
    			// if note priority not set, it means note is "normal" so priority "2" set at runtime
    			if(!$note->priority) $note->priority = 2;
    			//$notePriority = str_repeat("&#42;",$note->priority);
    			$notePriority = $priorities[$note->priority];
    			//fa-comments, fa-comments-o, fa-comment, fa-comment-o
    			$commentsCount = "<span class='fa fa-comments-o'><span class='dn_note_comments_count'>{$note->dashboard_note->count()}</span></span>";
    			$priorityClass = " " . $priorityClasses[$note->priority];
    
    			$metaDivider = "&#47;";
    			$meta = "{$date} {$metaDivider} {$author} {$metaDivider} {$commentsCount}";
    
    			##################
    
    			$out .=
    				"<div class='uk-margin-bottom'>" .
    					"<div class='uk-card uk-card-default uk-card-hover' id='note-{$note->id}' data-note-value='{$note->id}'>" .
    						"<div class='uk-card-header'>".
    							"<div class='uk-grid-small uk-flex-middle' uk-grid>".
    								"<div class='uk-width-auto'>".
    									"<i class='$notePriority'></i>".
    								"</div>".
    								"<div class='uk-width-expand'>".
    									"<h3 class='uk-card-title uk-margin-remove-bottom'>{$note->title}</h3>".
    									"<p class='uk-text-meta uk-margin-remove-top'>{$meta}</p>".
    								"</div>".
    							"</div>".
    						"</div>".
    						"<div class='uk-card-body'>".
    							"$text".
    						"</div>".
    						"<div class='uk-card-footer'>".
    								$viewMarkup .
    								$viewEditDividerMarkup .
    								$editMarkup .
    						"</div>".
    					"</div>".
    				"</div>";
    		}
    		$out .= "</div>";
    		return $out;
    	}

     

     

    • Like 2
  16. So just had time to play with the HTML/CSS output...it would much more easies if we could use uikit markup.

    Just make some dirty changes in renderNotes() and get a fine working responsive grid with uikit cards...if i fin the time i could send you a PR with a own view for uikit theme users...(color and some special CSS classes are missing)...

    dashboard.thumb.JPG.0d44a8a37167180d3f1a91464083d572.JPG

    A Fonticon chooser for the single notes would be a other option to differ the single notes, than fiddling around with colors...?

    Best regards mr-fan

     

    • Like 3
  17. No i think these are very good examples of kind of application that you are looking for and Bernhard let us take a closer look into his building process and decissions...so many things to learn ?

    Welcome to Processwire!

    On 2/26/2019 at 6:27 PM, jmartsch said:

    Boy, I love our community. So helpful and friendly. Never experienced anything like this. Spread the love.

    @jmartsch just like you - this forum its kind a like a save harbour for straightforward and friendly people getting their things done and help each other...

    • Like 3
  18. I don't wanna waste to much words on this but i have to write you my feelings

    a) i love the concept and design from ryan!
    b) and i love how constructive and good are all the input on this topic is! (no bashing or i would do it in red...or somehting like that)

    I know that such a open disscussion could take many wrong turns on other places, but not here!
    Great people here - wish all a great 2019

    • Like 10
×
×
  • Create New...