Jump to content

froot

Members
  • Posts

    707
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by froot

  1. @Jan Romero thanks, what you're saying makes good sense. Creating pages instead of repeater items for each post input seems a good solution, provided that those pages can be admin only. However, for this particular use case, I prefer to have all user submissions on one page, just would make things much easier for my intentions. So I would need to create a template for that new admin page which includes a repeater field or ProFieldsTable field (I have been using that), right? Do I do that in the templates section of the admin area ("add new template") or programatically? It seems to me like those admin pages and templates are created differently… I think that's what I struggle with mostly. Also, creating a custom fieldtype is something I would love to be able to do, just couldn't wrap my mind around it yet.
  2. is there a way to store the user input (post) in some custom admin page? I don't need a new page for each submission, just one page, not visible to the user, only to me in admin with a list/table of all user submitted data.
  3. yes that's the one. I had the issue before a long time ago. still recovering from racking my brain back then
  4. I'm doing if ($config->ajax) { echo "THIS IS AJAX"; $this->halt(); } else { echo '<div id="content">'; echo 'THIS IS MY REGULAR CONTENT'; … echo '</div>'; } and I use $config->prependTemplateFile = '_init.php'; $config->appendTemplateFile = '_main.php'; $config->useMarkupRegions = true; $config->useFunctionsAPI = true; in the config.php However, the site stills loads the entire page in the ajax response, which is not what I want of course, I get the header and menu etc where I render the response (result.innerHTML = response); suggestions?
  5. I'm trying to understand the basics of module development in PW. I'm quite confused with the structure of it. what I put figured out so far… the object class "Process" is going to be applied as a "process" to the admin page and attach to the top menu of the admin panel. The function __execute is what puts content on this page. Here's my first question: How can I add input fields for content to be added to the database? then you have the module itself that will appear in the modules tab (and page tree under admin but hidden). There I can add input fields via the class ModuleConfig and the function __construct am I right? but also, you can navigate to the modules section, overview of all site and core modules (and uninstalled ones and new ones) where you can see another "settings" button which doesn't appear on the module's detail page. (a bit weird, isn't it?) anyways, long story short, I'm quite confused about the different classes and which one I should actually use when building a module and how to know. I might add that I'm not a php expert, though I have built a bunch of websites with some rather complex templates in PW already, I still haven't touched any of this stuff. Maybe it's still some of my lack of understanding of php (also need to learn about the difference of implements and extends for example) but I feel that these PW classes are somewhat arbitrary. So is there a way to get more clarity on that?
  6. Hello all, I'm familiar with HannaCode and use it on some projects already. Now I wonder what it actually is good for to apply it as a text formatter on a template field. Here's what I'm trying to accomplish and where I thought it would be a good solution to use custom code for. For a shop "module" (not yet a PW module, but some php and javascript files) I'm working on, I need a way to allow for stacked prices, say a different unit price when buying 10 units. So since these unit prices and stack price rules would differ from product to product, I thought a very simple, fast and flexible solution would be to allow for custom code injection. So for example the content manager could write: if($itemAmount=10){$unitPrice=30}else{$unitPrice=35}; Does that make sense? So long story short, I need custom code on specific pages. Is that possible with the HannaCode Text formatter?
  7. only removes the first opening double quotes, the second closing double quotes stay ?
  8. also… if ($page->isChanged('seo_title') || $page->isChanged('seo_image') || $page->isChanged('seo_description')) return; is there a nicer way to do this?
  9. I'm trying to add hook before the page is saved. Then it should check if the SEO fields are empty and if so, use page's field's values that make sense. let me illustrate: $wire->addHookBefore('Pages::saveReady', function($event) { $page = $event->arguments[0]; if (!$page->id) return; if ($page->isChanged('seo')) return; if ($page->seo->title == '') { if ($page->template == 'speaker') { $page->seo->title = $page->academicrank.' '.$page->givenname.' '.$page->lastname; $page->message(':D'); // just to make sure the conditions are set right :D } else { $page->seo->title = $page->title; } } $event->arguments(0, $page); }); Something like this. I do get the message : D, so the issue is not there. However, the seo title field stays empty. Any ideas why this is not working?
  10. is there a $sanitizer method that can remove quotes? I need to remove them for SEO.
  11. also, sharing via facebook is not embedding the image. It seems to work fine with twitter and linkedin but not facebook. I'm using the module MarkupSEO to declare the social media image. When simply sharing the page-url on social media platforms manually, it seems to work fine, so that module doesn't seem to be the problem. However, I added <meta property="og:image:url" content="<?php echo 'http://'.$_SERVER['HTTP_HOST'].$page->poster->url; ?>" /> (as suggested further up) in case that's required for fb because the MarkupSEO-module doesn't provide that tag. Doesn't help though. And then also, I do not quite understand what the following means ?u={url}&title={title}&text={text}&media={media} these are placeholders? what goes in here for real? Lastly, I should mention that on the page itself, the image is not displayed, i.e. not included in the <body>, because it would be redundant with an embedded iframe on the page, so we left it out. Don't know if that's the issue. Thanks for help!
  12. nice module. Could you also make it possible to just copy the current url? What I mean is add another button that when clicked copies the current url to the clipboard. I'm trying to accomplish that with the current options of the module but no luck. Maybe if I could hook the function before rendering there would be a chance…
  13. webhost told me NTLM is not supported by our mail server, server runs Linux (Debian). What to do?
  14. it is, namely OpenSSL/1.0.2u
  15. This module doesn't send mails anymore, though it used to before. The module cannot connect to the email server: [0] string(87) "could not start TLS connection encryption protocol: STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT" and also: C STARTTLS S 220 2.0.0 Ready to start TLS Starting TLS cryptographic protocol could not start TLS connection encryption protocol: STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT I spent hours searching the error. Now I realised that our host uses php version 8.0.14. Might this issue be related to the php version?
  16. I need some sort of module like, or why not the exact module that is used in this very forum to add tags to a page. You start typing, it suggests tags, you select a tag from the list OR you type a tag, hit tab and the new tag is entered (is it added to the list of suggested tags too?). I have used TextInputAwesomplete before for other projects, just tried to use it again but it's quite stubborn and not exactly what I had in mind. Thanks for help!
  17. I tried $item->delete(); but it didn't work. Never mind, I just use the Admin Actions module instead. Thanks anyway.
  18. on a side-note, I find the PW API quite inconsistent, anything I try to solve with the API to avoid doing changes by hand involves a lot of research and forum thread writing and reading and trial and error, because every field seems to work a bit differently, and so it's really time consuming and defeats the purpose of avoiding to do it manually.
  19. what's wrong with my code, why doesn't this work?! $hidden = $pages->find("template=cast, status=hidden"); deleteHidden($hidden, $pages); function deleteHidden($hidden, $pages) { foreach ($hidden as $item) { $pages->delete($item); } }
  20. OK I'm a step further. I thought the following would work but it does not: $suckers = $pages->find("template=cast, include=all, sort=id"); $language = user()->language->title; $language = strval($language); foreach ($suckers as $s) { if ($s->body != '') { $s->of(false); $s->cast_language = $s->cast_language->title.'|'.$language; $s->save('cast_language'); $s->cast_language->save(); $s->of(true); } else { continue; } } Don't know where the issue is, it seems to not really save it properly. I never know which one to use: $s->save(); $s->save($field); $s->$field->save(); Thanks for help.
  21. cast_language is the select options field's name. It has options (multiple checkboxes) as follows: 1=English 2=Deutsch That matches the title of the available languages. I edited my original post and added the foreach loop to make things clearer.
  22. what I want to accomplish is to actually allow the pages to be english AND/OR german, so they can in fact be english AND german. I want to give the content manager full control over which page is shown in which language. So the problem remains that when I run my code, the value of the selectoptions field gets overwritten and I just don't know how to simply add to the array instead. I'm sure it must be possible somehow.
  23. I have an array of bilingual pages. These pages have a body. If the body is filled, it's in the array. So the array is different in english than in german. Criteria is the body. I want to change that though and use a SelectOptions field as criteria instead. That field would be a multiple value checkbox SelectOptions field with values as follows. 1=English 2=Deutsch Now I want to check one or two of these options for each page via API. Something like: foreach ($suckers as $s) { // :D if (user()->language->title == 'Deutsch') { $s->of(false); if ($s->cast_language == "") { $s->cast_language = "2"; } elseif ($s->cast_language == "1") { $s->cast_language = "1|2"; } $s->cast_language->items->add(1); $s->save(); $s->of(true); } if (user()->language->title == 'English') { $s->of(false); if ($s->cast_language == "") { $s->cast_language = "1"; } elseif ($s->cast_language == "2") { $s->cast_language = "1|2"; } $s->cast_language->items->add(1); $s->save(); $s->of(true); } } But I think that's nonsense, still cannot tell from the documentation how to approach this. The issue is, the array depends on the user's current language, so in order to use this function to set the values right I need to run it once in German and once in English. But at the second run it will overwrite the values of the first run. Don't know how to add to the array of selected options. Thanks for help!
  24. I have some html in a body field of a page including some <a> tag. For some reason the last bit of the link appears in the head in some meta tag and it breaks the page, the text appears on top of everything else. It must have to do with a faulty parsing of the html, meaning the closing of the <a> tag break the entire html but I have no idea how to fix it. The body is a CKEditor field. So it's like: <p>whatever whatever, <a href="https://www.domain.com/whatever" rel="noreferrer noopener" target="_blank">blablabla</a>.</p> and then I see on top of the page above all other content: blablabla. " /> Any ideas?
×
×
  • Create New...