Jump to content

Pip

Members
  • Posts

    77
  • Joined

  • Last visited

Posts posted by Pip

  1. Hi everyone!

    Prolly this is the most noobest question.

    But how do you work on date times in Processwire templates?

    I've been working on one that will check if it's the current day and not over a certain time.

    PHP wise it's easy. But on a Processwire template, it spits out as an error.

    $wholedatetime = DateTime("now", new DateTimeZone('Asia/Singapore') );
    $currentdate =  $wholedatetime->format('Y/m/d');
    $currenttime =  $wholedatetime->format('H');
    	echo $page->batchdate;
    if ($currentdate != $page->batchdate) {
    	if ($currenttime < 23) {	
    		$formflag = 2;
    	}
    }

    Help!

  2. Hi guys,

    Testing out to create a new page from HTML.

    First one sucked because I used "&" rather than "." to join strings. Now I'm stuck with a blank page which I can't edit or deleted. :( Literally when I mouse over, nothing comes up. Help! OCD  brain not working.

    Thanks in advance!

     

     

    image.png.2e28d724d21d9c37b2a9d98837a07a15.png

  3. @elabx bet it got you excited.

    Don't think it's a typo. Especially if you do a print_r($batch);

    	<?php
    			// Check if today is in a batch
    			$batches = $pages->find("template=batch, batchdatestart<=today, batchdateend>=today");
    		
    			foreach ( $batches as $batch):				
    		
    			print_r($batch);
    		?>

    And this is the output (now):

    image.thumb.png.8590d75715f013f25eac267ab597a67b.png

    Here's a screenshot of the template now (not touching it now I swear!!)

    image.png.ec6f59118057a35e5ddf015326e21b95.png

     

     

     

  4. Hi all.

    I think I am being punked.

    I created a template called "batch" where I have "slotstotal" which is integer/text to store the value. Oddly, I have entered a value in on a page using the batch template via the PW admin. But when I do a print_r, I got this.

    image.thumb.png.483241d520097d64fa883b38c3d14ebd.png

    I thought the field is bugged so recreated it with a different field name. Now when I refresh the page, I still got the same screen. (I tried changing the page a bit and it does reflect but the print_r is still the same. 

    😞

     

  5. 11 hours ago, BillH said:

    One thing I'd try is using Pages > Find to make the same selection, and then simplified version, and see if you get any results. If you have debug set to true in config.php, you can see the selector being used towards the bottom of the page.

    Another thing would be to try displaying the results of the find using the selector – and variations of it – on a page using print_r(). Or if you have Tracy Debugger installed (highly recommended!), return the result using bd().

    BTW, it might be more efficient and a little easier to debug if you find and loop through the pages something like this:

    
    $batches = $pages->find("template=batch, batchdatestart<=today, batchdateend>=today");
    foreach ($batches as $batch) ...

     

    Debug is now on.

    Thanks on the efficiency. Implemented it.


    As for print_r, I got these.
     

    Quote

     

    ProcessWire\PageArray Object ( [count] => 1 [items] => Array ( [Page:0] => Array ( [id] => 1018 [name] => prosciutto [parent] => /ingredients/ [template] => ingredient [title] => Prosciutto ) ) [selectors] => )  


    ProcessWire\PageArray Object ( [count] => 1 [items] => Array ( [Page:0] => Array ( [id] => 1040 [name] => mushroom [parent] => /ingredients/ [template] => ingredient [title] => Mushroom ) ) [selectors] => )   

     

     

  6. Hi Everyone

    Need some help on page reference (PR) field type in repeaters. I've checked other threads and it seems straightforward by referring to the object name and down to "title", "name" etc.

    I tried it on my side and it seems "title" and "name" and "id" of the PR is blank. But if I refer to the object itself, the page ID is given no problem. Problem is when I try to query the page (ingredient template) using $pages->find, it returns none as well.  I did strval none (yes was that annoyed).

    Some background:
     

    Quote

     

    batch (template)
       - menu (PR, checkbox for pizza template)
       - start date
       - end date

    pizza (template)
        - topping (repeater)
             - ingredient (PR)
             - quantity (textfield) --- how many of the ingredient is being used in the pizza itself

    ingredient (template)
         - name
         - quantity (textfield)  --- total number in stock

     

    What I am trying to do:
    I am trying to create an online order form for a pizza place where menu rotates and comes in batches. In the order form (page), it will check if today is in any batch. If yes, it will display all items in the menu BUT provided they have the available ingredients (ingredient->quantity > 0). 

    My problem:
    I can't query the page which is weird and I need to check if there's still some stocks. 😞 See codes below.
     

    		<?php
    			// Check if today is in a batch
    			foreach ($pages->find("template=batch, batchdatestart<=today, batchdateend>=today") as $batch):				
    		?>
    			<br>
    			Title: <?php echo $batch->name; ?><br>
    			<?php 
    				// Print pizzas available today
    				foreach ($batch->menu as $menuitem): 
    					echo $menuitem->title . "<br>&nbsp; &nbsp; &nbsp; Ingredient: <br>";
    					// Print ingredients of this pizza
    					foreach ($menuitem->topping as $pizza):
    						// The problematic line belo. 
    						// If $pizza->ingredient->title/name/id, none appears. 
    						// If $pizza->ingredient, page ID appears BUT if you use in the $pages->find, it returns none.
    						echo  $pizza->ingredient . "<br>";
    					endforeach; 	
    				endforeach; 
    			?>
    		<?php endforeach; ?>


     

     

  7. On 12/23/2020 at 1:41 AM, MoritzLost said:

    Hi @Pip, thanks for reaching out, I think I know what the problem is. The module should work with any number of templates and on any number of fields. However, before creating a link for a given title, the module checks if the page the title belongs to is actually viewable. I made this the default because for a "normal" use case it doesn't make sense to create a link to a page the current user can't actually view. Based on your screenshots it looks like you display all hero abilities on the page for that hero, so I'm guessing the hero abilities don't have their own sub-pages in the frontend? If there's no hero-ability.php template, no hero-ability pages will be viewable, so the module will not create any links for those.

    In version 4.0.0 of the module I added a checkbox to disable the viewable checks for use cases like this one. Your screenshot looks like your site has an older version installed, so make sure to update to the latest version if you don't see the checkbox. After the update the option should appear in the new configuration fieldset Markup and output settings.

    By the way if my assumption is correct, you may want to use the hook TextformatterPageTitleLinks::buildTitleMarkup to modify the link for hero-ability pages to point to that ability on the hero page instead (using anchor links). See my answer here for details.

    If that doesn't solve the problem: I've written a bit about how to check what the module is doing in my answer here, use that to determine whether the module (a) is not finding the desired titles or (b) is finding the titles but not creating links for them. This can help you find out what's going wrong. Let me know if you need more help!

    Hi @MoritzLost Tried your recommendation. You're right the hero-ability.php was non existing. Recreated it and is now linking automatically! Thanks so much! Happy Holidays!

    • Like 1
  8. Hi @MoritzLost

    Thanks for making the module. It's really handy for sites that have majorly a lot of pages. 

    I'm working on a game site where there are heroes and their special abilities, items, etc. . Was totally delighted that it was working on my test environment but I noticed that (sorry if it feels snobbish but itemizing helps me think lol)

    1.  hyperlinking only works on the Body textarea
    2.  it only works on one page template so it seems 

    I have two templates - hero and hero-ability. They're both in the module settings. 

    I've also counter checked that my textarea fields have the same settings as the Body textarea.

    Did I do something wrong? Or did I misunderstand something? Thanks. 

    screenshot-d2g-2020_12.22-23_26_26.thumb.png.59bccb50585a6579e28622a8339c1469.pngscreenshot-d2g-2020_12.22-23_28_50.thumb.png.c61da2491d25e4c923c8e5ed5c433203.png

    1770033707_screenshot-d2g-2020_12.22-23_28_50(1).thumb.png.a577895c155f96dde17bf43310b4403b.png

    1335448505_download(2).thumb.png.343aed1a4f9f9741ed95939fa416bd30.png

    • Like 1
  9. 21 minutes ago, Pip said:

    Hi everyone!

    Was wondering if anyone been getting this error when you import? 
     

    Been scratching my head on this. Checked 515 and this is what I got. 

    
    		if($page->id && count($page->get('ImportPagesCSVData'))) {

    Any idea what's tripping it? 
     

    PS: Import goes in still btw. Whether if it's correct or not, I have to double check as I've added in hundreds. 😕 

  10. Hi everyone!

    Was wondering if anyone been getting this error when you import? 
     

    Quote

    Warning: count(): Parameter must be an array or an object that implements Countable in D:\XAMPP\htdocs\d2g2\site\modules\ImportPagesCSV\ImportPagesCSV.module on line 515

    Been scratching my head on this. Checked 515 and this is what I got. 

    		if($page->id && count($page->get('ImportPagesCSVData'))) {

    Any idea what's tripping it? 
     

  11. On 8/16/2020 at 4:05 AM, Pip said:

    I tried changing my admin email address. It's still stuck with the old one. Searched the whole database as well as any hard coded ones, none. 

    What sorcery is this, @ryan

    ---- Sincerely, dumbfounded struck confused noob PW user. 😂

    So apparently after going through stuff the reason as to why the email address never changed is due to the XAMPP settings. Despite setting the settings that way, it overwrites the sender still. 

    Oh wells. Silly me calling it sorcery. 😆

  12. Hi guys

    Just want to confirm something before I go calling the ghost busters or something. So here's aroughsummary.: 

    • I'm currently working on a Xampp environment. 
    • Each site I work on, I customize the domain from localhost -> confabulations. No .com, .net, .org, etc.
    • I've installed processwire and it automatically sets this in the config: 
      $config->httpHosts = array('confabulations');
    • Everything works well in Login/Register until one day, I get this error when I register on the site (locally). 
      image.thumb.png.b723ddf14a544db41d0ae154f22d6b4c.png

    Which is weird because I have not been customizing the module itself. Not until I change this: 
     

    $config->httpHosts = array('confabulations.com');

    Then it works. 

    I mean sure fine theoretically if I change my vhost etc to confabulations.com it should work. But what I do not understand why suddenly trigger such error when the only modules I have is the Sitemap and Login/Register/Profile. 😞

     

  13. 9 hours ago, 7Studio said:

    $config->adminEmail = 'my@email.com'; $modules->LoginRegister->execute();

    Tried this. Though theoretically it is sound, email address is still stiff. I got my admin email address still.

    Worst even if I do this, my Login Register comes out empty. 

    I have do this in order to work (just to have the module work work): 

    9 hours ago, 7Studio said:
    
    <?php $config->adminEmail = 'my@email.com'; ?>
    <?=$modules->LoginRegister->execute(); ?>

     

    Take note: Email address is still the same as admin.

    I've checked the error logs, everything seems to be in  working order. 

×
×
  • Create New...