deltavik
Members-
Posts
28 -
Joined
-
Last visited
Everything posted by deltavik
-
Instead of putting your content in body field, create fields for each section in your page template. Then render each section in its own HTML section. <section id="sec-a"> <h2><?php echo $page->title; ?></h2> <?php echo $page->sectionA ?> </section> <section id="sec-b"> <h2><?php echo $page->title; ?></h2> <?php echo $page->sectionB ?> </section> <section id="sec-c"> <h2><?php echo $page->title; ?></h2> <?php echo $page->sectionB ?> </section>
-
a css framework like bootstrap or foundation can make your life easier with menu-toggle and responsiveness. As far as testing across devices is concerned, safari has built-in support for viewing your site across devices.
-
dont think you need to secure htaccess. If it were important, PW would've mentioned it. Moreover, at least in wordpress world, there are third-party plugins that need to edit htaccess file.
-
So I thought of hooking up with hooks. I installed that "hello world" module, and now, when I save a page, I see "Hello world..." message on top -- which makes sense. To play with it further, I copied the hook code from the module to my header.php file. The code is: $pages->addHookAfter('save', $this, 'example1'); function example1($event) { $page = $event->arguments[0]; $this->message("Hello World 2 ! You saved {$page->path}."); } It is a verbatim copy of the code from the module, and it is placed in a file that gets called first via prependTemplateFile in config.php. However, now when I save a page, I don't see the message from my hook function. What could I be missing? thanks,
-
To lock and protect the file, you will have to modify its permissions on the file system. To do that, you will have to execute "chmod 400 config.php" on command line. There is no "setting" inside config.php. To run that command, you will have to gain ssh access to the server. If ssh is not your thing, you can change file permissions in your FTP client as well -- at least most FTP clients support it. In your FTP client, right-click on config.php and and click on file permissions. Then set the permissions to 400.
-
Seems like you want Can you give an example of any website that does what you want? That may help us in answering your question.
-
I am using font awesome in my PW project, and I can confirm that PW doesn't interfere with fontawesome rendering. To troubleshoot, first, try to get your FA icons to work in a plain HTML file outside PW. If that works, then move over fa icon elements into PW files.
-
since you are this far in troubleshooting, I assume you had also cleared the site/assets/sessions folder?
-
By any chance, did you add cloudflare or something like that? I ran into this issue recently. The session logs said "Error: Session fingerprint changed (IP address or useragent) (IP: 108.162.219.219)." That IP address is Cloudflare IP. Then, after searching on this forum, I added sessionFingerPrint = false in config.php. The problem then went away. Good. However, the next day I removed that line to test the login/logout issue. Interestingly, I didn't notice any issue. So -- I don't really understand why the problem didn't reappear after I removed that sessionFingerPrint line.
-
wow. That's a powerful script. I am going to use it. I had been running poor man's backup with these lines as cron. 0 0 * * * mysqldump -uusername -ppassword databasename | gzip > /var/www/backups/sql/sql_$(date +\%m-\%d-\%Y).sql.gz 0 0 * * * cd /var/www/backups/files && zip -r files_$(date +\%m-\%d-\%Y).zip /var/www/docroot/site/assets/files 0 0 * * * find /var/www/backups/sql/ -mtime +7 -delete 0 0 * * * find /var/www/backups/files/ -mtime +7 -delete The first two back up the database and files folder at midnight. The last two remove backups older than a week.
-
I am on pw 3 and this is the code that works for me. I am new to PW and haven't yet caught up with hooks -- I got this code from somewhere here. <?php $pages->addHookAfter('Page::path', null, 'hookPagePath'); function hookPagePath(HookEvent $e) { $page = $e->object; if($page->get('template') == 'article') $e->return = "/$page->name/"; } This code that updates the urls is the first half of the redirection game. The other half is about redirecting users to the right article. For that, you will have to use urlsegments. Here are the steps, roughly. -- Enable urlsegments for homepage. => This means website.com/this-is-an-article is a hit to the homepage, and this-is-an-article is the first url segment. -- Use this url segment to get a handle to the article page object. ==> $pages->get("name=this-is-an-article") -- Check if its a legit article by checking for the existence of its id. -- If it's a valid page, redirect the visitor to it. echo $article->render(); return;
-
Fatal error when moving site from localhost to Hosting
deltavik replied to Krlos's topic in Getting Started
Just dropped by to say that I have the same setup on my laptop (MAMP + php7 + PW3), and I was able to migrate the site to live (lamp + php7) without any hassles. In my view, PW version is not the reason. One suggestion I have to troubleshoot this situation: -- Load the default, out of the box PW3 on your hosting. -- If that works, then gradually add modules and import templates + fields one at a time until you hit the error. -
Yes, something like this was the pseudo code in my head. For this case, I went with sql query straight up. Given the high number of articles and authors, I thought it will be efficient if I just do a private, one-on-one chat with the database. The selector-trick will be useful for smaller datasets.
-
helpful threads. Seems like many people have run into this situation. I thought I missed something in the tutorials.
-
thanks @Can for the wirecache example. That will come handy. I am thinking of running the sql query directly to get results. This seems quite efficient. And, I will also cache the results of this. This is my query: SELECT count(pages_id), data as author FROM field_authors GROUP BY data ORDER BY count(pages_id) DESC LIMIT 10;
-
Hey guys, I thought I had selectors under control until I ran into this situation. This is my structure of four templates: Articles - Article Authors - Author Article contains a pagefield for author. If I wanted to get all articles written by an author, I can run a selector such as "template=article, author=$authorName". So far so good. Here is where I am stuck: I want to display a list of top 10 authors with the most number of articles written. In other words, I want to write a selector that - finds items with template=author - sorts descending by the count of articles written by author <-- I am unable to formulate this part - limits items to 10 One way to solve this is: Get a count of articles by all authors in a php array. Then sort the resultset by article count and get author names for the top ten in the array. This method can be heavy on both database and php, depending on the number of authors and articles in the system. Is there a selector-only trick to solve this problem? thanks
-
Performance considerations -- find vs get, and routing
deltavik replied to deltavik's topic in Getting Started
oh yeah. thanks for reminding me. -
Performance considerations -- find vs get, and routing
deltavik replied to deltavik's topic in Getting Started
@ryan -- thanks for the info. Makes sense. It's my Handover from the wordpress times where one has to often think about query efficiency... especially for a large-ish site. @bernhard Jumplinks looks promising. I am experimenting with it now. thanks. -
Hey guys, I have two performance related questions. Question 1. find vs get In my setup, I have a template called 'article,' which is a child of 'articles.' There are two ways to get all articles. This: $pages->get("/articles")->children; or this: $pages->find("template=article"); And if I wanted to further filter the articles by author , the queries would look like these: $pages->get("/articles")->children("author=john"); and $pages->find("template=article,author=john"); I think "get" would be faster in such situations. What are your thoughts? Are there any best coding practices for PW performance? Question 2: URL Routing The article urls in my old site are in this format: http://domainname.com/article-url. But, in PW, the urls look like this: http://domainname.com/articles/article-url. For URL redirection, based on what I was able to find on the forums, I made the homepage accept url segments. Then I route the requests based on the url segment (which essentially is the 'name' of the article page.) The question now is -- how big of performance hit will the site take due to this routing? Or am I needlessly thinking too much? thanks,
-
yes, I noticed unticked radio options too. For some reason, the screencap software that I use sometimes leaves radio and checkboxes unchecked.
-
This looks interesting. I am going to try it. thanks,
-
OK, I finally got it to work after several trial and errors. It worked after I removed "allowed template(s) for children" under categories. Earlier, I had it set to Category -- just the way "Architects" template had it set to "architect" in skyscraper demo. Attached is the screenshot of my new settings. I am unable to tell why it worked, but it did. Maybe it is due to some mis-configuration elsewhere. I will keep digging. thanks everyone for help.
-
I think I have the restrictions right. Attached are the screenshots of the family sections of category and categories template. I am now using InputfieldChosenSelectMultiple instead of PageListSelectMultiple -- no difference. thanks,
-
Hey guys, I am struggling with "new page from input field" feature. I think I have made correct settings, but when I go to create a new page, it shows me a list of existing pages, but not an option to add a new page. This is my setup. I have three pages: Story, Categories and Category. Categories is the parent of Category page. In story page, I have a field called categories of type "page". For this field, in "Input" section, I have followed the instructions to allow new pages to be created from field. 1. Both a parent and template must be selected above. -- The parent is set to Categories, and template is set to Category. 2. The editing user must have access to create/publish these pages. -- YEs. 3. The label-field must be set to "title (default)". -- It is set to title (default) See the attached screenshot for the field settings. The interesting thing is -- if instead of Categories, I select "home" as the "parent of selectable pages," it works. I then see the option to add new page. But I want the parent to be Categories. I have also compared my categories field settings with "architects" field setting in skyscraper demo. I am missing something somewhere, but cannot point to it. Any suggestions? thank you
-
Bingo. That hit the spot. However, I had to press enter, not tab, to make it work. I will try it in another browser to check tab vs. enter situation...but in any case, it solves my problem. thanks