Jump to content

Livusa

Members
  • Posts

    6
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Livusa's Achievements

Newbie

Newbie (2/6)

0

Reputation

  1. Adding the slash to the end did it! Thanks much, @zoeck!
  2. Thanks for your reply, @pwired! I did the same ? , and in plain html/php everything works as expected.
  3. Hello, I have a strange issue that I do not seem to be able to resolve. I have a simple form that I'd like to process via an ajax POST call using vanilla Javascript, not JQuery. However, the variables do not seem to be passing to the template file (I have an ajax_handler page for which the template file is _ajax_handler.php which is where I'm sending the call). I think I have already tried everything (including changing single quotes to double quotes -- yeah, I'm desperate) but I can't get it to work. This is my js: let submit_form = document.getElementById('addToCart'); submit_form.addEventListener('submit', updateCart); function updateCart(e) { e.preventDefault(); let params = "modelId="+ document.getElementById('modelId').value + "&pieces=" + document.getElementById('pieces').value; let xhr = new XMLHttpRequest(); xhr.onload = function() { if(this.status == 200) { //for testing purposes, only logging the response console.log(this.responseText); } } xhr.open("POST", "/ajax_handler", true); xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhr.send(params); } And this is all I have in the _ajax_handler.php template file, currently responding with 'Notice: Undefined index: modelId in C:\Users\livia\source\kykdesign\site\templates\_ajax_handler.php on line 17': echo $_POST['modelId']; Can someone advise what I am doing wrong or what is some obvious thing that I'm missing? Some PW setting or template setting maybe? Thanks much.
  4. Thanks @PWaddict! I have tried your syntax, too, but it still gives me the ‘Missing required field’ for the title when I save it first. ☹️ Can it be some setting I have differently? Or the fact it’s a multilingual page? Just guessing here. I mean, no big deal, I can work around this from the front-end, I just hate that I don’t understand what’s causing this.
  5. Thanks much, @kp52 and @dragan! To rendering on the front-end: that part is clear. However, I would like to have this behaviour upon creation of new pages in the Admin, if possible.
  6. Hello there, I am fairly new to PW and PHP (spoiler alert: totally new to hooks). I am trying to add a few custom functions to the Admin for certain "patterns" that will be repeating throughout the site I am building. One example of such a pattern is this: I have a 'product' template with a Page Reference field for single page input, 'design'. Once selected, I need to set the title of the product page to the title of this design. I have added the below to the ready.php (pieced together based on whatever I have read up here, feel free to laugh ?). It does the job, but only in 2 saves, as upon the first one it throws a 'Missing required value'-error for the title, although the values do get visibly filled in. Can someone help me out with where I am going wrong here or how else to approach solving this? $this->pages->addHookBefore('saveReady', null, 'buildTitle'); function buildTitle($event) { $page = $event->arguments(0); if($page->template != 'product') return; if($page->template = 'product') { $p = $page->design; $page->title = $p->title; } } Thanks much.
×
×
  • Create New...