Wanze
PW-Moderators-
Posts
1,116 -
Joined
-
Last visited
-
Days Won
10
Everything posted by Wanze
-
Make sure that the script creating the pages is also UTF-8 encoded.
-
Hi uuragoda, Welcome to the World of ProcessWire, enjoy! Now to your question: You are limiting the number of news entries to twelfe. Could it be the case that there are more than 12 items? Maybe you're just missing sorting the news entries, e.g. by a date field or by the native created field: $items = $pages->find("parent=/about/newsroom, limit=12, sort=-created"); // Get the latest news by created date, descendant sorting
-
PageArray::has() only accepts a single object. You need a loop, here's an example: $found = false; foreach ($user->locations as $location) { if ($page->locations->has($location) { $found = true; break; } }
-
@Peter Rename your field to "first_name". PHP does not support variables with dashes. else if(!$input->post->first-name) echo "First name exists, but is blank"; From the code above you can't say if it's empty or does exist, because NULL or EMPTY are casted implicitly to false by PHP. You'd need the following distinction: if ($input->post->first_name === null) { echo 'First name does not exist'; else if ($input->post->first_name === '') { echo 'First name exists but it\'s empty'; }
-
Hi Olli and welcome! Sorry, I don't understand the question. Is "titles" your repeater field? What do you want to filter? Can you give an example and your structure? Cheers
-
Another approach: You could add a checkbox "inactive" to the users template. Then hook after login and if this checkbox is checked, return false.
-
Yes, you can specify the GET vars that should be cached or bypassed. In addition, ProCache can also cache url segments.
-
I also suspect a bug somewhere. I faced this problem with a 2.6 installation, on my localhost
-
I'm not sure I understand the question. After the form submission, you know which PDF's are checked. Now on the confirmation page, you simply can read the selected page-IDs (corresponding to the PDF pages) from the POST request and display a list with those pages. If you redirect to a confirmation page, you could store the PDF page IDs in the session.
-
@pwFoo Report back here if you have any issue with the hook. Another possibility would be to prefix your styles with the template and put everything in one CSS file, e.g. .home.style1 { background-color: green; } .contact.style1 { background-color: red; }
-
What kind of configuration do you have in mind? There is a setting to specify the path to a css file. When it comes down to change the configuration dynamically to have multiple CSS files, it's hard to introduce a config setting that would fit everyone's needs. That's where Pws hooking system is the best solution IMO.
-
Hi pwFoo, It should be possible with an autoload module that hooks before Pages2Pdf::createPDF. Delete the styles.css file in /site/templates/Pages2Pdf folder, so that the module does not add styles from this file Create a new autoload module (or use an existing one) and add the following code into the init method. // Inside an autoload module public function init() { $this->addHookBefore('Pages2Pdf::createPDF', function($event) { $pages2pdf = $event->object; $page = $event->arguments('page'); // Set a custom css file for the template of the page where the PDF is generated $cssFile = wire('config')->paths->templates . 'pages2pdf/' . $page->template . '.css'; $pages2pdf->wirePDF->set('cssFile', $cssFile); }); } I did not test this code, please report if it does work or not work Cheers
-
Thanks for your information hheyne, glad it works!
-
could not get post values of a form submission
Wanze replied to adrianmak's topic in General Support
Yep the problem is the one tpr describes. Beside that, you should consider the following: Don't build your urls manually, let ProcessWire do it for you: $action = $pages->get('/checkout/')->url; <form action="$action"> Sanitize input $id = (int) $input->urlSegment1; // Must be an integer Cache the page you're searching; I'm sure that ProcessWire also returns a cached page, but in theory, each $pages->get() call fires an SQL query: $myPage = $pages->get($id); // Assign the found page to variable $myPage if ($myPage->id) { // Make sure we found a page echo $myPage->title; } Escape output $title = $sanitizer->entities($myPage->title); echo "<input type='text' name='product' value='{$title}'>"; Edit: This is only needed if your title field does not have the "HTML Entitiy Decoder" textformatter applied. Cheers -
The init() method is a good place because ProcessWire calls this method after the module is loaded and before "processing" the request (if autoload). Thus your are sure that the hook is registered before the hooked method is called. In this case you are registering a hook, not executing it. You're telling ProcessWire that in any point of time, when the render() method on a page object is called, it should afterwards execute your "addInlineScript" method.
- 14 replies
-
- hook
- non autoload
-
(and 1 more)
Tagged with:
-
Added a check to make sure the user downloading a PDF has view permission, thanks again Bernhard for finding/suggesting this! https://github.com/wanze/Pages2Pdf/commit/30810213ae939ccc3fc033765570c91c9be47cdd Cheers
-
I'm not up to date with this topic, but I quickly checked some sites.. I'm also seeing those spam entries like "buttons-for-your-website" and "best-seo-offer". Not sure what to do against this though... I'm wating until someone posts an easy solution Btw I don't like the new analytics interface, really had trouble finding the relevant stuff..
-
How to insert scripts and stylesheets from your module?
Wanze replied to hdesigns's topic in Module/Plugin Development
This method has a major drawback, as you might load unnecessary scripts from the backend (other modules running in the backend will use this array also for storing scripts/styles). A better apporach IMO would be if the module uses its own array to ensure that only the needed files are loaded. -
I think you're misunderstanding registering/executing hooks. When you register a hook, you do not call anything. Basically you tell ProcessWire that you want to execute custom logic whenever the hooked method is executed. In your case, your method "addInlineScript" is called after Pw rendered your page (after executing $page->render()). Autoloading just makes sure that your hooks are properly setup, before hooked methods are executed. You don't need autoloading, but then you must be sure that "registering" the hook happens before Pw executes the hooked method. Sorry if the above does not make any sense, it's not easy to explain this stuff as non-native english speaker/writer
- 14 replies
-
- 3
-
- hook
- non autoload
-
(and 1 more)
Tagged with:
-
I have the feeling that this should be handled by google itself, who's interested in spam visitors?
-
Hi Bernhard, In its current state, the Google Analytics module does display a uesful subset of the available analytics data. In my opinion, it's not the job of the module to filter out data. I would suggest to create another module which does this job. Or maybe I'm misunderstanding something? Can we filter out those spam entries when querying data with the API?
-
Hi BernhardB, Thanks You are right, thanks for mentioning this. I'll add the check! The current system is secured that you must choose the templates allowed to generate PDF files. If a user does change the page ID and the template of the requested page is not allowed to create PDF's, nothing happens. However, if the template can generate PDFs and at the same time has restricted access, then this is a problem.
-
Quote from the docs See: https://processwire.com/api/modules/markup-pager-nav/