-
Posts
4,314 -
Joined
-
Last visited
-
Days Won
80
Everything posted by diogo
-
jquery is a solution. I was already thinking of looking for the UL and replace it with a preg_match You can't play with urlSegments here, because the post template that is being called with render() is not aware of the real url.
-
If the structure of the page is the same, I don't see why you shouldn't include the header and footer in the categories template. People will never access the posts directly, so you don't have to keep them on the post template.
-
Ok, I went to your wiki post and reviewed it. I didn't get that you are outputting the head from inside the render()... on my example it was outside, and like that everything would work.
-
I don't get it. If you put the code for the breadcrumb exactly as it is on the default pw site on the header you always have home>news, independently of the presence of the url segment, right?
-
I'm a bit confused. This is the scenario that I'm seeing here. When you are on the category page, you have this url: domain.com/news/politics/ and this breadcrumb: home>news When you are on the post page you have this url: domain.com/news/politics/political-post and you want to have this breadcrumb: home>news>politics When using url segments you are still on the same page (fake parent), and the $page variable holds the value of that page. And this is what you want to have on the end of the second breadcrumb. No?
-
Joss, where are you putting the breadcrumb code? it should be on the category template, not on the post template. So, in my code, $page refers to the specific category page ("politics" in your example).
-
As you maybe noticed, FontSquirrel doesn't have a custom preview text on the font list. I just found a very neat extension to take care of this https://chrome.google.com/webstore/detail/fontsquirrel-preview/amjelmhhimmobojbpoccmilajoalncem
- 1 reply
-
- 2
-
-
I forgot to put the condition. Already updated the code, can you try again?
-
The breadcrumb is easy. if you don't do anything you already have the breadcrumb of the category page that will be something like home>categories, and you need to add the link of the category you are in, that in this case is exactly this page. echo "<ul id='breadcrumb'>"; foreach($page->parents as $parent) { echo "<li><a href='{$parent->url}'>{$parent->title}</a> > </li>"; } if($input->urlSegment1) echo "<li><a href='{$page->url}'>{$page->title}</a> > </li>"; // add this echo "</ul>"; Edit: I forgot the condition. Code is updated with it.
-
Unfortunately I'm not that near Solihull
-
You can also simplify the links to: <a href='{$post->name}'><h4>{$post->title}</h4></a>
-
Good You should throw a 404 in case the page doesn't exist. I will update my post above to include the necessary line.
-
your template should look something like this <?php include("header.php"); if($input->urlSegment1){ // code for the post page $post = $pages->get("/content-management/posts/$input->urlSegment1/"); if(!$post->id) throw new Wire404Exception(); // throw a 404 in case the page doesn't exist echo $post->render(); // you can put all the output code on the real post template }else{ // code for the categories page foreach ($posts as $post) { echo "<a href='{$post->name}'><h4>{$post->title}</h4></a>"; echo "</div>"; } } include("footer.php"); Edit: added the Wire404Exception() to the code and simplified the links
-
What i posted doesn't have anything to do with the loop. You should use thomas's code to create the links, and my code to output the post in the modified urls. The loop (and all the other code) should go in the categories template on the part where I wrote "// code for the categories page").
-
Have a look at the lower right corner of the page you are in
-
try this on the categories template if($input->urlSegment1){ //get the post $post = $pages->get("/content-management/posts/$input->urlSegment1/"); echo $post->title; }else{ // code for the categories page }
-
@Wanze, the logic-view separation makes all the sense in the scenario that Antony referred, but to me it's perfectly possible to keep PHP very discrete inside the HTML with the PW sintax. @Anthony, your team's workflow seems perfectly logical and healthy to me, but it still implies some understanding of what each other do. You show understanding for the designer's work when you worry about letting him have his code as clean as possible of PHP, and he has to show some understanding of your work by trying to understand how some basic but important programming things work. He has to know how a loop works and where his HTML should go inside it, or how a condition works, etc... and if he gets that on a template engine, he will also get it with PW as long has you are careful to keep all your complex code on another file.
- 74 replies
-
- template engine
- twig
-
(and 8 more)
Tagged with:
-
Welcome to the forum luzox! What is the markup that the dropdown has to have?
-
Agree with all above, but even with the workflow you referred, I don't think PHP is more dangerous than a template engine sintax because in that case, all the PHP will have to be very simple as you will have to implement a trully MVC system, right? If so, because all the complex logic will be out of the "view" files, you will always have very simple and not dangerous PHP code for the designers to work with: <?= $page->title ?> or at the most: <div> <? foreach($page->children as $child): ?> <h3><?=$child->title?></h3> <p><?=$child->body?></p> <? endforeach; ?> </div>
- 74 replies
-
- template engine
- twig
-
(and 8 more)
Tagged with:
-
Must be on the template file because the echos are not inside a function edit: actually they are . But still it must be on the template file
-
Can we create social network in Processwire?
diogo replied to Vineet Sawant's topic in Getting Started
Luis makes it sound easier than it is , but if you have the time it's certainly possible. Here are two examples of how to implement "adding friends" and "articles wall" just to give you an idea (written in the browser from my mind and very very very over simplified): //adding a friend $new_friend = $pages->get("template=user, name=$input->post->new_friend"); //assumes that a friends field of page type with all other users was already added to the users template $user->friends = $new_friend; $user->save; //outputing a wall of articles only from the user and his friends //creating a string with all the friends separated by a pipe character (OR) to put in the selector $friends = ""; foreach($user->friends as $f){ $friends .= "|" . $f; } //find the articles from the user ($user) and his friends ($friends) and render them echo "<div id='wall'>"; foreach($pages->find("template=article, created_users_id=$user$friends") as $a){ $a->render(); } echo "</div>"; edit: modified the second example to use the buit in selector "created_users_id". -
And for quick reference http://processwire.com/api/cheatsheet/#selectors