Jump to content

Vigilante

Members
  • Content Count

    47
  • Joined

  • Last visited

Community Reputation

2 Neutral

About Vigilante

  • Rank
    Jr. Member

Recent Profile Visitors

1,906 profile views
  1. Yes, if I build the logic myself to parse a given URL string and figure out which part of the path goes to the segmented page. I just thought a function like this might have already existed. The logic would handle that. If "this/is/long/url" is a 404, then it looks for "this/is/long" and if that's a 404 then it looks for "this/is" and if it finds a page here, it would then check to see if segments are on. Then if so, it would return "this/is" as a page object. If segments are not on for that page (or accepted segment strings are defined and my string doesn't match them) then it would also return a 404 and give up. Obviously this kind of recursive checking would be more costly in processing so that's why a dedicated function or a switch would turn it on only when necessary.
  2. It's not that I'm doing "custom routing", it's that I want to return the correct page that handles a particular URL. If I have "/some/page/here" and I "look it up" with whatever function might exist, it should return "/some/page/" if that is the correct page that handles that particular URL (because segments are on). I'm not trying to do custom routing here, I'm trying to lookup the correct page that handles a given URL. I'm only talking about routing because the PW router obviously already uses/has this logic. It knows the correct page to open for a given URL. I'm simply looking for similar function in the API that works like get(). I pass in a path and it returns the page that handles it. For some reason I thought this would be a pretty common thing to want to do, unless very few people make use of segments?
  3. I don't think it's that broad or mysterious really. Let's say I have a path as a string that came from somewhere or is auto generated, etc. Something like "/this/should/be/a/page". Now I just need to check if that's a valid URL or not. If I simply throw it in get() it will return 404 because it won't find that exact hierarchy in the page tree. It would be a relatively simple thing for the code to knock off "page" and instead search for "/this/should/be/a/". And if that doesn't exist, look for "/this/should/be/" and then bingo. If "be" exists, PW checks to see if segments are turned on and if they are, check if segments are limited to certain strings. If not, then get() ultimately would return the "be" page. Of course, all this should be optional. So the default get() would return 404 as it does now. But if you had something like `get("/this/should/be/a/page/", array("look_for_segments"=>true));` then get() would search and return a segmented page if that exists. The bottom line is this, I'm looking for a page "this/should/be/a/page/" which is a totally valid URL ("be" has segments turned on). But instead PW tells me it's a 404 not found. That automatically says something isn't right here. I can't have PW telling me a URL is a 404, but if I actually GO to the URL, it works fine due to segments. The PW routing system already knows how to handle URLs with segments, I'm just thinking that functions such as get() need to make use of that logic as well. It doesn't even need to be get(), it could be an alternate function, perhaps gets() where the 's' stands for "segments" and it will return the page relating to a URL where segmented pages are searched for and not just precise page tree location.
  4. I have segments turned on for the root/home page. This is because I'm doing some custom routing to remove a path from the URL. One of the grandchild pages itself has segments turned on. So when I'm doing my custom routing from the home page, I look to see if the URL is valid by using a standard get lookup on the segment string. Something like `$pages->get("/myroute/".$input->urlSegmentStr()."/");` The problem is, the segment string may have a path that itself includes segments, like "/route/allows-segments/segment". So get() returns nothing, essentially going to 404, because it can't find that path which has a segment in it. Is there a way to make get() smart enough to see that even though /segment/ isn't found as a page, its parent /allows-segments/ has segments turned on and thus it can get that page instead? I already programmed my workaround, it's not that big of a deal. I had to specifically test for the segmented URL though. Luckily I only have one page like this, but I can see it being an issue if I had a lot of them. Perhaps get() needs some kind of options (or another finder function entirely) that can deal with paths with segments. Where it will process the path and check for segments, returning the proper page.
  5. Thanks. Looks like a lot of stuff there, I'll have to play with it and see if it does what I need. Will it work when using alternate admin themes?
  6. I haven't spent a ton of time on PW, just a handful of sites, but some things would make it easier to use. I bet there are plugins but I haven't spent a lot of time seeing what others use to solve this. 1) Easier access to the real name of a field. I often have a page open in the editor, a field label might say "Description" but really the actual code name could be anything, such as "Markdown" I see sometimes for md fields. Also field names seem to be case sensitive and I've worked on sites that seem to have random field names with caps or not. Is there a way to make it easier to read the code-based field name when I have a page open? The current method is cumbersome. From a page edit scree, switch to the Settings tab to grab a look at what template its using. Then open the template to see what the fieldname is. 2) Direct link to template from page. In similar vein, when I'm on a page in the Settings tab, it would be nice to have a direct link to open the template rather than look at it and then go find it in the UI. 3) Open a field directly from inside template edit screen. When I'm viewing a template and I see the list of all the fields, I want a direct link to open the edit screen of a particular field. --------- These three things are very common on client work because I don't always have every template and field name/label matched up and memorized. I'm constantly playing this dance of being in a page, then wanting to know the field name for code, so I have to go see what template it's using, then go look that up to see the fields, then look that up to see what field type it is, etc. For example, even bypassing having to open the template first would be good. If I could see a field and link directly to the field edit screen. If any of you have techniques to simplify this, I'm all ears, or plugins or whatever you use.
  7. Well, the 301 was wanted, But only for true guest users. These other users had multiple roles. I ended up adding the logic to test if they are logged in from the template itself. If this is a bug, it needs tested from a sandbox or fresh install. I don't know why it acted that way. I mainly wanted to confirm whether PW uses an additive or restrictive model for the permissions.
  8. I'm creating a recursive PHP function for showing a 3 level menu. parent - child - child - - gc - - gc - - - ggc - - gc - child parent - child - - etc This is all easy stuff with the recursive function but the problem is I want to use some logic that has to bubble up from the great grandchildren to the parents. If one of the menu items does not have any related pages, I don't want to show it. Like an empty category in a blog or something. Again this is easy to just test for during the loops. It gets tricky at the next part. If a parent or grandchild is empty, it will still have to show up if one of its children has a related item. So if any child has an item, its parent must show. And likewise, if some great grandchild has an item, it's parent and grandparent have to both show. A work in progress of the function looks something like this, I've removed some logic to clean it up like assembling the href and classes and so forth. This is the gist of it. function menu($p = null, $ignore = false) { echo '<ul>'; foreach ($p->children() as $c) { // $ignore contains a pageArray of items that can be ignored, already determined that these are empty // it's just that I don't want to ignore it if a child or grandchild DOES have items if (is_object($ignore) && !$ignore->has("id={$c->id}")) { continue; } echo '<li><a href="HREF" class="CLASSES">' . $p->title . '</a>'; // Recursive call here if ($c->hasChildren()) { menu($c, $ignore); } echo "</li>"; } echo '</ul>'; return; }
  9. This is exactly what I would have thought, but I got the opposite happening. WIth Guest role (view permission off) and a member role (view permission on), the user was redirected from the page. I'll have to read up on the rest of the links posted here. Thanks!
  10. All users on our site are given Guest role, but also other roles, for example Guest and Admin or Guest and Member, etc. When editing access rights for a template, it lets me set permission for each role, as well as what happens if a user doesn't have access, such as redirecting to another page. My question is about a user with two roles. They have Guest and they have Member. I also want to redirect them to the registration/login page if they try to access this template. The easiest way to do this (I thought) is remove View access to the Guest role. This way a Guest (non member, non logged in) would redirect to the login page. However it didn't work like that. When I am logged in (Member role), it STILL redirects me to the login page. So the question is, when I have multiple roles, is PW choosing the most restrictive permissions, or are the permissions additive? Why would it redirect me based on the Guest role when I am also part of a role that DOES have permission? Also, if I'm forced to have View permission on the Guest role, it completely makes the automatic redirection useless. If Guest users have to have View access, the redirect system can never actually work. It doesn't make sense. I'm assuming PW is choosing the most restrictive permissions when a person has multiple roles, but that seems wrong, I've only ever seen roles/permissions as being additive, gaining the permission of all roles assigned. I must be missing something, or perhaps the site I'm working on is wrong for having every user also be a Guest role? I've already read the docs for permissions and roles and it doesn't answer this question. How can my users be both Guest and Member, AND use the template redirection if not logged in?
  11. I had this exact same issue. I wonder why it's not more common to need, given the almost necessary use of a multi-page field in most sites. In any case, I solved it easy enough while maintaining all usual PW pagination tools, simply by using the normal find() anyway! $items = $pages->find("limit=10, id=". $page->page_reference); This returns functional paginated results and works fine.
  12. The first method might not be super efficient, but when would that efficiency be realized? I probably have an $everything with maybe 50 to 100 pages which separate into around 10 or 15 parents lets say. Is that efficiency causing me 3 seconds or a blink of the eye? The second method makes sense but isn't as easy to follow. If the speed difference is 5ms then at the end of the day doesn't really matter so much.
  13. Apparently the encoding is from PHP, as PW just uses the http_build_query() directly, and that uses RFC1738 encoding. However, it's confusing, because RFC1738 allows symbols like dollar sign, comma, and others as "safe" and do not require encoding. http://www.faqs.org/rfcs/rfc1738.htmlIt says this:"Thus, only alphanumerics, the special characters "$-_.+!*'(),", and reserved characters used for their reserved purposes may be used unencoded within a URL." But it is encoding those characters anyway. I just want commas in my url parameters and there is no way to do it. I ended up calling urldecode() on the return value from $input->queryString. I know this is probably not safe, but I need my unencoded "safe" characters!
  14. I used $input->queryString when creating URLs to maintain existing URL parameters. I need some parameters to be like a CSV string such as "?option=12,34,56,78". Commas are an allowed and safe character in a URL without needing to be encoded, however, the queryString function is encoding them as %2C which is ugly. "?option=12%2C34%2C..." Since this is a safe character and doesn't need encoding, can I tell queryString to not encode these characters? Or is something else causing this encoding to happen?
  15. I need to loop through the parents first as this creates the outer html portion of the output. Then loop through those child pages for the inner html for each parent. I just only want to include children which exist in the $everything array. If it helps. The $everything query is finding stuff from all across the site. I will need to put these into a ul->li list but organized by their parents. ``` <!-- loop each parent --> <section> <h2>Parent stuff</h2> <ul> <!-- loop child stuff under each parent --> </ul> </section> ``` So I have my $everything query, but I need it filtered, sorted, parsed out, whatever, by the parents so I can create each parent section such as in the above. My original logic was to create an array with the everything query, then loop through that to create another array that holds just the parents. Both of these arrays only contain unique pages. But now I need them cross referenced, looping the parents and only getting children that exist in the everything array.
×
×
  • Create New...