
deltavik
-
Posts
28 -
Joined
-
Last visited
Posts posted by deltavik
-
-
On 10/10/2016 at 7:18 AM, biber said:
Hi and thank you again,
yes, @Klenkes, you are right, this was my simple solution to hide the menu. I've tried some methodes to solve that menu open/close problem, but for I use only pure html and css, I did not find another good example yet. For me it sounds logical: I want to go to the next page - click on Menu - the long menu appears - I choose a page - the menu vanishes again.
@dragan: I know about that issue, but did not find the reason yet. All other links work OK, but the top links 'Pflanzenhof' and 'Gartengestaltung' should lead to the part of the menu belonging to that part of the nursery. For that I use the following code, slightly modified from the main menu:
<?php include("./_head.php"); ?> <div id='haupt'> <ul> <?php echo '<img src="'.$page->logo->width(300)->url.'" alt="'.$page->logo->caption.'" title="'.$page->logo->caption.'">'; // top navigation consists of homepage and its visible children $grouppage = $page; $children = $grouppage->children(); /** * Recursive traverse and visit every child in a sub-tree of Pages. * * @param Page $parent root Page from which to traverse * @param callable $enter function to call upon visiting a child Page * @param callable|null $exit function to call after visiting a child Page (and all of it's children) */ function map(Page $parent, $enter, $exit=null) { foreach ($parent->children() as $child) { call_user_func($enter, $child); if ($child->numChildren > 0) { map($child, $enter, $exit); } if ($exit) { call_user_func($exit, $child); } } } map( $grouppage , function(Page $page) { echo '<li><a class="men" href="' . $page->url . '">' . $page->menutitle . '</a>'; if ($page->numChildren > 0) { echo '<ul>'; } } , function(Page $page) { echo '</li>'; if ($page->numChildren > 0) { echo '</ul>'; } } ); ?> </ul> </div>
I am still learning and am very glad to have the friendly help from you all.
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.
-
2
-
-
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.
-
1
-
-
Seems like you want
10 hours ago, Dakrtom said:I would like to create a home ProcessWire be shown on the various articles or posts . When I click on the title of the article I müchte I am redirected to the orignal article . I hope my question is understandable Greeting TomCan 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.
-
1
-
-
50 minutes ago, alan said:
I didn't @deltavik but I too am puzzled why the problem came up. My hosting is a fixed IP, so am I.
I wonder if there is somewhere a way to 'clear' existing fingerprint 'expectations' so I would then be able to return the setting to default and all would work. It seemed really odd that my Android would:
# fail to login
# fail even though I cleared all history (etc, all items all time)
# quit, Chrome, rebooted phone
# BUT would work if I used the same device, same app (Chrome) in incognito modeClearly my device in non-incognito mode is fingerprinted on my PW install and when it's seen won't work - I wonder how I clear that..?
since you are this far in troubleshooting, I assume you had also cleared the site/assets/sessions folder?
-
1
-
-
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.
-
3
-
-
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.
-
3
-
-
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;-
5
-
-
On 8/13/2016 at 6:48 PM, Krlos said:
Yes is installed.
I'm going to rebuild this site in PW 2.7 because I can't find how to fix this.
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.
-
1
-
-
12 hours ago, Nukro said:
I would do something like you mentioned:
$articleCountPerAuthor = array(); foreach($pages->find("template=author") as $author){ $articleCount = $pages->count("template=article, author=$author"); $articleCountPerAuthor[$author->title] = $articleCount; } arsort($articleCountPerAuthor); // result of $articleCountPerAuthor /* array( "Actor XXX" => 500, "Actor XXX" => 400, "Actor XXX" => 200, )*/
$pages->count() - little overhead, since it doesn't load the pages like $pages->find() does
arsort() - Sort an array in reverse by array value
Since Processwire is extremly performant and efficient in handling pages you shouldn't have Problems.
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.
-
18 hours ago, Robin S said:
Getting the authors with the most articles would be simple if the article pages were added to author pages rather than the other way around, but of course that's not so good for workflow. But there have been some posts on the forum that suggest linking two Page fields, where changing one updates the other.
These may also be relevant:
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;
-
1
-
-
Hey guys,
I thought I had selectors under control until I ran into this situation.
This is my structure of four templates:
Articles
- ArticleAuthors
- AuthorArticle 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
-
9 hours ago, ryan said:
make sure you are using <link rel='canonical'> tags in your document head
oh yeah. thanks for reminding me.
-
-
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,
-
1 hour ago, ottogal said:
It seems strange to me that in your screenshots of the Family settings of Template Categories none of the radio options is ticked. Something wrong with that?
(Of course, the Categories page must have children allowed.)
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,
-
1
-
-
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.
-
-
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
Single Page "ScrollTo"
in Getting Started
Posted
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.