Jump to content

joe_g

Members
  • Posts

    239
  • Joined

  • Last visited

Recent Profile Visitors

4,656 profile views

joe_g's Achievements

Sr. Member

Sr. Member (5/6)

25

Reputation

5

Community Answers

  1. @Robin S I can confirm that this works really well. it's a relief, honestly - I expected having to dive deep int sql for this. One thing that doesn't seem to work is to match things in quotations "Alice One" and "Alice Two" will both be considered related because of the same first name "Alice", regardless of quotes or not. But that's fine in my case.
  2. Thanks!, I edited my post above while you responded. In the mean time I've realized that my misunderstanding is that I can't replace parent regions, then the child regions will be destroyed. Like, I can't have this and update both foo and bar directly using replacement <div id="region1"> foo <div id="region2"> bar </div> </div> i would have to do <div id="region1"> <div id="region1inner"> foo </div> <div id="region2"> bar </div> </div> However, as you suggest, I can add to the parent like (using the code from my previous post) <div id="maincontent" pw-append> added this to main </div> <div id="testregion"> replaced </div> ..as long as i don't replace the whole parent. This makes sense, since I suppose this is some form of string replace behind the scenes awesome, and thanks again Ryan! J
  3. Thanks for getting back about this! Here is a test (using tailwind css). _main.php (global) <body> <div id="maincontent"> </div> </body> _testregion.php (appended to template 'test' under files tab) <div id="testregion" class="border border-red-600"> default value from _testregion.php </div> test.php (actual PW template) - note the nested divs, how testregion is inside maincontent. <div id='maincontent'> <div class="p-8"> <div id="testregion"> should be inside red border? </div> </div> </div> What I'm trying to do is to apply my own "markup pattern" called testregion to an arbitrary position, but it doesn't do what I expect. Instead of getting "Should be inside red border" inside the red boder, i get _testregion.php appended after the output of _main.php. The result looks like this: However, it does work if I specify the innermost region in test.php, like <div id="testregion"> should be inside red border? </div> That means i can't match arbitrary regions that are inside each other, it would always have to be the innermost region(s)? This means that the site structure (the markup hierarchy) has to be entirely defined inside _main and I can never specify some markup that is simultaneously a parent and child. Maybe this is a good thing, I'm not sure. But this is what got me before.
  4. Hi there, I just discovered markup regions while looking for some templating solution. I've got a couple of layouts that are shared across a bunch of regular PW templates, and I'm looking for a way to abstract this, so that i don't need to have the same code duplicated across multiple places. I would like to keep the HTML "direct", so rather <div class="<?=$somePhp?>"> than, say echo "<div class=\'{$somePhp\}"> I think that rules out all regular delayed output strategies. Markup regions seemed perfect on the first look, but there are some limitations, if I understand it right 1. There is only one global markup region file (ie. _main). I can't use an arbitrary template file for some specific situation (like _myArticleLayout, for example) 2. I cant inherit templates, or chain, or stack them, or similar. I can't apply first _main, and then another one _article, for example 3. Related to this, I can only do appendTemplateFile globally in config.php, but I was hoping I can do this in the top of each template, or maybe even for parts of templates Now, some questions. Is there a better way to do this? Another templating engine? Is there a way I can use the magnificent markup region replacement engine myself, separately? Or did I simply misunderstood how this works? As a sidenote it seems I can't get nested regions to work, perhaps because I'm not using this the intended way? many thanks
  5. Hello, I'm lost with my Matrix (profield) and how to look for data using selectors: I have a matrix ("grid"), it has a 'matrix repeater type' mp4 that contains the fields 'mp4' and 'ratio' (and others): Under admin / repaters in the backend, things look a bit cryptic: Now, how do I find the mp4s that doesn't have a ratio? I would imagine something like wire('pages')->find("template=repeater_grid,mp4!='',ratio=''"); ..but I can't get any meaningful results back. If I could only get all mp4's, that would already be a good start... many thanks J
  6. Thanks, I used your code and did this: if($input->get('setlang')) { $session->set("userLanguage", $user->language->id); } else { $langId = $session->get("userLanguage"); if($langId) { $newUrl = $page->localUrl($langId); if ($session->get("userLanguage") && $langId !== $user->language->id) { $session->redirect($newUrl); } } } ..but then I realized it doesn't work together with caching... Duh. I guess it's localstorage or nothing?
  7. Hi there, I've got a client who would like to store the selected language, if it's not the default language. The only way I can think of is to use localstorage from js, but that would mean loading the whole front page, then reloading it again in the right language - ew! Is there a better way that vibes with the built in language functionality? I'm hoping to avoid session cookies and such. Also, I'm not sure how the language redirect really works. I suppose it's done in htaccess somehow, but to capture it before it happens I wouldn't know where to 'inject' that functionality. maybe the best solution is to not bother?
  8. Thank you both! I feel I have a lot to discover now! Hopefully I won't make another vue app for a while 🙂 J
  9. Hi there, I had a brief look at livewire and hotwire - and I love the concepts behind them. I really dislike having to choose between making a SPA or a server side site, the two paradigms are so different and hard to mix. If I understand live-/hotwire right it could mean a single paradigm for both client and server data manipulation, which I haven't experience since visual basic 6 :P To be able to model a regular PW site and then sprinkle it with app-like behaviours here and there would be absolutely incredible. I almost considering stepping over to Laravel for this reason, but it's a big step for me. Neither livewire or hotwire seems to exist without Rails or Laravel. So this seems to be a must. Anyone had experience with this, or something similar? Is there something similar that would work with PW?
  10. Oh wow, if this works the way i think it does this could really be it. I can combine **= with limit=20, for example and only get the most related. Thanks! ps. I've been meaning to learn more about selectors, they've really expanded last couple of years.
  11. Popularity has it's use, and I'm doing that as well for a different visualization. But in this project I'm mainly looking for similarity. "obscure" similarity is more important than "popular" similarity. Lets say a project have 1000 project that share some popular tags, but there is only 2 that share the same (obscure) tag - on top of the popular ones - those 2 are the most important to show. If I prioritize popularity those 2 projects will be buried somewhere. This probably needs to be some custom sql, just not sure how to write it.
  12. Thanks both. RockFinder looks great, didn't know about that module before. But I wonder if it can do what I need. I suppose bot findRaw and rockFinder would need to first load all pages that has 1 or more keywords in common - in my case that can be a lot of pages since some keywords are very generic. Lets say I have 20k projects and half of them might have the keyword "collaboration". What I need is the intersection of the most common, and only the first 'X first' hits. I suppose the only way that can be done is with sql, since the data is purely relative (unlike how rockFinder works, there is no dataset to "start" with - i can't start with 10k pages). Now, how to solve it haha - that's going to be a bit challenging.
  13. Hi there, Is there I can sort by "number of things in common". For example, I have "projects" with "tags". I'd like to show the 20 projects that is "most related". So first show the projects with 3 tags in common, then 2 tags in common, etc. Perhaps something like: $pages>find("template=project,limit=20,tags={$tags},sort=in-common-[tags]") Is there a way I could do this in a scalable manner? (As in, avoid getting all results and loop through them)? Custom SQL? thanks!
  14. Thank you! Indeed it worked, after adding the namespace. It's embarrassing but I still don't full understand namespaces. Or rather, I kinda do but I'm not sure when I need to declare "namespace ProcessWire;" in a PW template...
×
×
  • Create New...