-
Posts
450 -
Joined
-
Last visited
Everything posted by bwakad
-
I have found useful tips here for sure. But I also wonder if it helps when changing some basic things. For instance - normal way - we access a page, include head.inc, include some other things, include foot.inc - other way? - we have 1 page which holds head.inc and foot.inc, access a page and include it. The way I see it, in the normal way, especially with scripts and all, we have to load every time head.inc and foot.inc in the other way, we load it once, and only load the page which we access Although I do not really know what it will do with get/post requests....
-
Either it's the code (IF / FOREACH / INCLUDE) things, or the .js files (foundation/google)... My page content loads quick, I just see in the top of my mozilla tab a spinner for at least a second. <head> looks like this: <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title><?php if($page->name == "profile") echo "{$user->name} "; echo $page->get("headline|title"); ?></title> <meta name="description" content="<?php echo $page->summary; ?>" /> <meta name="generator" content="ProcessWire <?php echo $config->version; ?>" /> <link rel="stylesheet" type="text/css" href="<?php echo $config->urls->templates?>mystyle/foundation.css" /> <link rel="stylesheet" type="text/css" href="<?php echo $config->urls->templates?>mystyle/override.css" /> <script type="text/javascript" src="<?php echo $config->urls->templates?>myscript/vendor/modernizr.js"></script> <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script> footer scripts are these: <script type="text/javascript" src="<?php echo $config->urls->templates?>myscript/vendor/jquery.js"></script> <script type="text/javascript" src="<?php echo $config->urls->templates?>myscript/foundation/foundation.stickyfooter.js"></script> <script type="text/javascript" src="<?php echo $config->urls->templates?>myscript/foundation/foundation.js"></script> <script type="text/javascript" src="<?php echo $config->urls->templates?>myscript/foundation/foundation.topbar.js"></script> <script type="text/javascript" src="<?php echo $config->urls->templates?>myscript/foundation/foundation.tooltip.js"></script> <script type="text/javascript" src="<?php echo $config->urls->templates?>myscript/foundation/foundation.abide.js"></script> <script type="text/javascript" src="<?php echo $config->urls->templates?>myscript/foundation/foundation.alert.js"></script> <script> $(document).foundation(); </script>
-
Oops. Sorry Diogo - I used wire("page->parent") - my mistake (hope I can say that the last time)
-
Yesterday, I have used the first example as Nik pointed out later. But with my second code (below) I ran into problems with the $page->parent->get("name"); I then rolled back to my original code which was placed on the template file itself. I do want to thank all for thinking with me as it's been a great learning exercise and probably turn to the function on a later time. if ($page->parent === $page->rootParent) { // if parent of this page is rootparent $field = $page->parent->get("name"); $selects = $pages->find("template=child-template, {$field}={$page->id}, limit=2, sort=-created"); // example field = provincie, page id = child
-
As I try to make code as short as possible, I would also like to have as less code as possible. The main thing for me is less resource heavy. So I made 3 examples for a way to use my menu. Each have advantage and disadvantage. I would really like to know, which one is quicker. Because as my pages grow, so will the resources... // it is less likely the ID will change while names can be changed and the code stay the same echo "<li><a href='{$pages->get(1026)->url}'>{$pages->get(1026)->name}</a></li>"; // more static, but when changing the page name, the code need to be rewritten echo "<li><a href='{$config->urls->root}members/'>Browse Members</a></li>; // automatic, although I'd probably need a IF for excluding menu items $menu = $pages->find("template=browse, parent=1, sort=title"); foreach ($menu as $item) { ?> <li><a href="<?php echo $item->url ;?>"><?php echo $item->title;?></a></li>
-
do you mean: foreach needs to be inside the function? as owzim suggested? I also get a error on the get() on a non-object inside the function itself. I am guessing I can't use a function : that is based on the page I am on without using the foreach in the function and because get() can't (yet) be used. My layout is different on certain pages, so I can't really put all of that inside a function. I thought I could simply make the $selects = change by using a function... bummer
-
This is normally my code: if($page === $page->rootParent) { // if this page is rootparent $selects = $pages->find("template=child-template, limit=2, sort={$page->name}"); // example provincie // We have sorted by page-name if current page is a rootparent. } if ($page->parent === $page->rootParent) { // if parent of this page is rootparent $field = $page->parent->get("name"); $selects = $pages->find("template=child-template, {$field}={$page->id}, limit=2, sort=-created"); // example field = provincie, page id = child // We have sorted by date DESC if current page is a child. } // on browse inc is simply the foreach($selects as $child){ include("./myinclude/browse.inc"); // browse.inc holds html for display But in this normal code I have my layout and names visible. while with the function I get simply ID's. That's what puzzles me...
-
Yes, I understand that. Strange thing is, if I use the $selects = like from my original code, and after this include a file with layout and all, it simply works. Just not when I use $selects = inside a function because I need to use echo as suggested. So when I write it as code, after include my layout it works. When I echo function() and include my layout it doesn't.
-
Normally I use something like this : if($page === $page->rootParent) { // if this page is rootparent $selects = $pages->find("template=child-template, limit=2, sort={$page->name}"); // example provincie // We have sorted by page-name if current page is a rootparent. } and on my template: foreach ($selects as $child){ and then the usual: echo $child->title // etc. I did, and I get some results, but it brings me back to id nrs... when I use the normal code on the template page itself (without function) I get my results the way intended...
-
my code now looks like this, but no output - must be doing something wrong but have no idea what...: //functions.php function selector() { $selects = wire("pages")->find("template=child-template, limit=2, sort=company"); return $selects; } //mytemplate.php selector(); foreach // etc
-
Does anyone know how to use this code in a function? I have had no luck with it so far. Once I read some were to use wire->pages but could not find more info about it. function selector($selects){ $selects = $pages->find("template=child-template, limit=2, sort=company"); return $selects; So I can use it on some page as : selector();
-
Of course it is also because they don't know PW. The majority of developers say they develop. They charge huge amounts of money while they simply click and install. That is certainly not developing. And yes, their advantage is there is a huge amount of themes and plugins, and because other software from their start was not so easy, there is a huge amount of people using it today. Just take a look at themeforest forums, or respective developer websites, and you will understand there are so many flaws in themes and plugins the only benefit are for those whom creates these flaws. As a example, you install WP, install a theme, then plugin 1, 2 and 3. Now they conflict. Developer plugin 1 says, take it up with developer from plugin 2. But that one tells you, it is an issue in your theme - go there for support, and that one probably will tell you to update WP (again, if possible). etc. etc. etc. Bloggin. As I understand one can make a page/article in any software and let people comment. This is also available in PW. Commercial support. There is certainly more reason to doubt Wordpress/Joomla commercial support. Themes e.g. Profiles. In PW it's all possible in the way you want. If you say you are developer in WP/Joomla, you will know PW better. Books about. As long as the processwire.com is available, who need books? Where I live, books are almost gone, density for internet is the highest. So, if one choose WP/Joomla: good luck with that! But nor for me ;-)
-
On this code, when login is not correct I get a internal server error. So the question is what I need to do? <?php if($user->isLoggedin()) { // user is already logged in, so they don't need to be here $session->redirect("/profile/"); } // check for login before outputting markup if($input->post->user && $input->post->pass) { $user = $sanitizer->username($input->post->user); $pass = $input->post->pass; if($session->login($user, $pass)) { // login successful $session->redirect("/profile/"); } } ?> <?php include("./myinclude/head.inc");?> <form action='./' method='post'> <p><label>User <input type='text' name='user' /></label></p> <p><label>Password <input type='password' name='pass' /></label></p> <p><input type='submit' name='submit' value='Login' /></p> </form> <?php include("./myinclude/foot.inc");?>
-
I can't say I use PW for a long time, but I as a basic php coder/designer (newbie) I am definitely sold to PW. Can't tell you enough how painful Wordpress and Joomla are. True there are many plugins available, but none of them are same preferred coding. On top of that they all interfere with CSS because of integration in these plugins. Many times, even if you find a nice theme, you end up searching which part was doing what that you want to modify. In the time I have used PW I never once looked back on other CMS because PW give me the feeling truly anything is possible. Besides, I like the learning curve of it. I also called some payment providers Mollie/iDeal to see if integration is possible, and of course it is. That will be the next fase in my website design. Thinking SEO, layout, coding, security, any kind of website - PW is my favorite!
-
Possible to register and login simultaneously
bwakad replied to onjegolders's topic in General Support
This was a really nice example. I now have a working registration. Checking is done by foundation abide.js with patterns - which means upon typing, wrong format gives a nice silent error at that field. And if any not right, checking is also done by PW - I get a nice alert at the top of the form for that. I made hover tool-tips for more info on the required fields. Successful registration moves them to the 'member' role - which means they can still only view and need to apple for other special roles, after I confirm some things *. They are automatically logged in and redirected to their profile page. * There are 2 other roles: company and applicant. The reason for not moving them to these roles is that over here we can not auto confirm a chamber of commerce or tax number. So I think, a registered user 'member' is presented with a form on their profile page where they have to provide info that I can confirm in order to move them to other roles. -
So in the first foreach I need to cycle through the second one? edit - Maybe it's easier to just use $selects = pages->find("template=user"); in this case it's the superuser, which has right to see all... And I believe on the user template I can acces the field roles, am I right? edit - this did not work either Btw, does anyone know why the role guest is present in all other roles.?
-
I do not follow what you say... in what part?
-
I have this code, and 2 things do not work: sort by roles, and display the role of each user. I did read in the API I can use $type = $child->get("roles"); echo $type; but that seems a bit over the top, or not? Furthermore, as I understand, any extra role added will also be using the guest role. Why is that??? if($user->hasRole("member")) $selects = $users->find("roles=company"); if($user->hasRole("company")) $selects = $users->find("roles=member"); if($user->hasRole("superuser")) $selects = $users->find("roles=member|company, sort=-roles"); foreach($selects as $child) { ?> <row> <div class="medium-6 columns"><?php echo $child->name; ?></div> <div class="medium-6 columns"><?php // display role ?></div> </row> <?php } ?>
-
this works: if ($user->hasRole("company")) this only take the last into account: if ($user->hasRole("company | superuser")) this works for both (removed spaces): if ($user->hasRole("company|superuser")) So I guess the API is very strict on this... In either case by the role - company or superuser - I can get to the 'member' page (also template/file). But there this code only display results for the role superuser?: //members.php $selects = $pages->find("template=user"); foreach($selects as $member) { echo $member->name } EDIT --- solved it like this, at least I need to display contra according to role (but superuser needs to see all): if($user->hasRole("member")) $selects = $users->find("roles=company"); if($user->hasRole("company")) $selects = $users->find("roles=member"); if($user->hasRole("superuser")) $selects = $users->find("template=user"); // should this be changed??? foreach($selects as $item) { echo "<row><div class='medium-12 columns'>{$item->name}</div></row>"; }
-
Okay, I have thought about it and decided to go with this: I make 2 roles - 1 for members, 1 for companies. login page 1. only visible in menu for guests. 2. after succesful login, check roles: member or company? a. if role is company - make members listing page visible in menu > redirect to profile page b. if role is member - make companies listing page visible in menu > redirect to profile page profile page - to edit their details only - probably I use $user->name as menu title 1. only visible in menu for logged in users. 2. check roles: member or company? a. if role is company - make owner role company details visible on page b. if role is member - make owner role member details visible on page listings page 1. only visible in menu for logged in users 2. check roles: member or company? a. if role is company - display list of members b. if role is member - display list of companies details page 1. only visible in menu for logged in users 2. check roles: member or company? a. if role is company - display requested member details b. if role is member - display requested company details With this in mind I need 4 pages, files and templates. The profile template would hold all required fields for member AND company, but only visible according to the user role (set in the template file). I hope I am doing this right...
-
I have a profile page+file+template which is used for the logged in user to edit their details. A logged in user can be either a company or a member. In a perfect world when someone is browsing my website, I would have a link somewhere saying "more about this member" or "more about this company" and linking to a page. Which means - another guest/member/company can only see some details on a page. But it puzzles me a bit since the user template, where extra fields can be added, is actually a core template file, and I read somewhere that it's main purpose is to be used in the back-end (I can be wrong). I would like to know how exactly people have set this kind of thing up. Because I do not think every member/company would have a seperate page, aside from the user details. But to be bwakad - I am a litle confused how to do this the easy way. In a former topic the solution to a user name which created a page was $child->createdUser->name; But in this particular case I can't use $child->createdUser->url; as a link because it would open up the admin folder because it links to the admin/acces/users/name. That make me believe I have to use a seperate page. Any suggestions are welcome
-
But as always - everyone is friendly enough to help. I will study the cheatsheet more - don't want to see any of you loose
-
heyyyy, that's even more easy then I thought. Can't believe I was goign for the difficult road. Thanks so much! So, where did you all found this code - where to look? Again sorry - I had to look under $page, while I was searching under $user/$users/$roles...
-
I did not find what i was looking for in there. I guess I searched in wrong area... What I need is a way to show a user's name which created a page. $user is only reffering to the current user (guest or logged in). But I need a way to show the name independent of logged in or not. I know I can do this: $myid = $child->get(created_users_id); echo $myid; But I do not know exactly how to access that page to get the name of the user. Think I have found the answer in the API... (sorry). I hope this is the fastest way to do this though: $myname = $users->get("id=$myid"); echo $myname->name;
-
I would like to see the code used in the admin for the menu - user part. Does anyone know where to look for that?