Jump to content

Jhin

Members
  • Posts

    11
  • Joined

  • Last visited

Everything posted by Jhin

  1. Hello, I have in the template blog_posts the field tag_country as InputfieldTextTags field, linked to the pages with template "countries". I know I can safely show how many linked blog_posts to countries i have with: <?php $desired_country = 1; $blog = $pages->find("template=blog_posts, tag_countries=$desired_country"); foreach ($blog as $blogItem) { # loop } ?> But how I can I get only the countries pages that has at least one item tagged? I tries something like this, but I'm feeling I'm missing a huge concept with nested subselectors. <?php $countries = $pages->find("template=countries, [template=blog_posts, tag_country=id].count>=1, include=all"); foreach ($countries as $country) { # loop ?> I hope you can help me, Thank you! ----------------- I found a solution using the owner selector: $countries = $pages->find("template=country_item, parent=$continent, include=all, tag_country.owner.template=blog_posts");
  2. Hello ngrmm I just found a workaround based on your input. class blogPost { const statusUnapproved = '16385'; } $page->addStatus(blogPost::statusUnapproved); if ($page->hasStatus(blogPost::statusUnapproved)) { echo "Unapproved"; } else { echo "Not Unapproved"; } Thank you for the help!
  3. Hello All, I've searching if there is any way to add a new status for a page. My web is very user based and I need another status page called "unapproved" for moderation purposes. I've tried looking at the API and also looking at this forum, but I did not find nothing. The code below produces this error: Warning: A non-numeric value encountered $page->addStatus('unapproved'); if ($page->hasStatus('unapproved')) { echo "Unapproved"; } else { echo "Error"; }
  4. Hello, Indeed, I already readed it. But something I think is not working properly. Docs mentions user's language will define which language will be served. I, as a logged member, always receive the default language even I specify 'it', 'de' or 'ru'. I have no way to force processwire to show the current user language option, it always show the 'default' language. I saw a lot of people looking how to prevent that, but I cannot find a working solution at the moment. ----------------------------------------------------------------- Solved, I figure it out looking at different forum snippets. This is the code I'm using on a new module. It also adds the $user->savedLanguage variable to receive the language name user has set on profile. I hope you find it useful. <?php class LanguageDefault extends WireData implements Module { /** * getModuleInfo is a module required by all modules to tell ProcessWire about them * * @return array * */ public static function getModuleInfo() { return array( 'title' => 'LanguageDefault', 'version' => 0, 'summary' => 'A work around to changing the default language.', 'singular' => true, 'autoload' => true, ); } /** * Initialize the module * * ProcessWire calls this when the module is loaded. For 'autoload' modules, this will be called * when ProcessWire's API is ready. As a result, this is a good place to attach hooks. * */ public function init() { if ($this->wire("user")->language->name == "default") { $this->wire("user")->savedLanguage = "en"; } else { $this->wire("user")->savedLanguage = $this->wire("user")->language->name; } $this->session->addHookBefore('redirect', $this, 'setDefaultLanguage'); } public function setDefaultLanguage($event) { if ($this->page->id == 1 && $event->arguments(0) == $this->page->localUrl('default')) { $event->arguments(0, $this->page->localUrl($this->wire("user")->savedLanguage)); } } }
  5. Hello all, I'm working on a website very focused on members and what I'm trying to do is to retrieve member desired language ("en", "it", "fr", "es", etc...) and then use this info to render correct language. language_01 is a page selector field which is linked to a $language object. I'm trying doing a redirect, but I'm really feeling frustrate regarding this feature. I take too long to understand that $user->language was based for backend and frontend is handeld via localName urls. $desired_language = $user->language_01->name; if (!isset($_SESSION['redirected']) OR $page->localName != $desired_language) { $_SESSION['redirected'] = true; $redirect_url = '/' . $desired_language . '/'; / header("Location: $redirect_url"); exit; } Do you have any other approach? I saw a lot of snippets but required the member input and I was looking to make it in a more automatic way.
  6. I'm using the Multi Instance feature from Processwire 3: https://processwire.com/blog/posts/multi-instance-pw3/ Truely, your solution is really simple, I think I can work it with the URL slashes. Thanks for your idea, maybe there's another solution, if anyne has another idea, will be highly appreciated. Thanks.
  7. Hello there! First off, sorry about my english. Excuse me if you find any type of typo or my way to write seems weird. I love processwire. I've using it for a long time but just right now in trying to go a little bit further. I have a main domain where processwire is installed. From another subdomain where processwire is not installed, I'm trying to make a full custom website. Everything works fine, using the Multi Instance tutorial I've been abble to load data and port user session from one instance to other. But, I've got a problem. When I do the <?php echo $site->page->url(); ?> The output is /subdomain/page1url/ which is correct because my web hierarchy is Home - subdomain - - page 1 - - page 2 But I would love make the url to be only /pageurl/. Can be this done? Should I hack .httacces or there is any other workaround to make this done? Thanks for your support.
×
×
  • Create New...