-
Posts
4,296 -
Joined
-
Last visited
-
Days Won
79
Everything posted by diogo
-
Olá Bruno, sim sou Portugês Isso deve ser um problema com o mod_rewrite. Segue estas intruções http://processwire.com/talk/topic/1962-cant-reach-admin-page/?p=18373
-
Martind, he was laughing at me, not at you
-
Do the links on the website work?
-
Hey, no problem!! I'm glad you solved it.
-
Already Impressed, but a Bit of Trouble...
diogo replied to MatthewSchenker's topic in Getting Started
Hi Bruno! Did you try all the suggestions on this post and the posts that netcarver linked to? -
Module - Shop for Processwire - Selectable options and the cart
diogo replied to NooseLadder's topic in Modules/Plugins
Apart from the if statement, the code is perfectly valid. In this case It's working because by enclosing the statement in quotes it becomes a string, and a string is always true. The problem is when you need it to be also false, because it never will... Ryan's example won't work because 5/6, 7/8 (etc) are less than 0. Maybe by testing if there is at least one child where the field is not empty? if($page->children->get("product_size!=")->id) -
but you wouldn't have a way of knowing if the post is being accessed from the real or the fake url.
-
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: