Jump to content

Deyan

Members
  • Posts

    7
  • Joined

  • Last visited

Everything posted by Deyan

  1. Hi @adrian, thank you very much for your fast reply and fix. It works. I just tested it with few entries. You are a life saver!
  2. Hi, can this module import images? I saw somewhere that it can but it does not work for me. Normal text fields and everything else works great but no images. I also tried every possible path that I could think of, even remote url but no results. And no errors. If this helps, I'm on latest PW 3.0.123, PHP 7.0.1 (tried higher version, no changes). Clean install of PW and only BCE as module. Since I'm on Windows (10) I run Xampp or Wamp. Tried both, same result. Everything but images works. Any ideas? I only need one image per page but I have over 2000 images.
  3. Aha, thank you very much. I need this only for admin part. I found some old module that does exactly what I need PageListBetterLabels. It trows some errors but I fixed it. Again, thank you & pozdrav.
  4. Hi all, this is my first time to try to use hooks and I'm a bit lost here. What I need is to make a hook that changes title after page is saved. Basically it only adds selected date (field: cal_start_date) to title after page has been published so the end title looks like "2019-05-15 My title". This part works ok (though I think my code is bad). The problem is when I edit page and hit Save button, it changes title to "2019-05-15 2019-05-15 My title" which is not what I want. It should not change title after edits. Here is the code so far: public function init() { $this->pages->addHookAfter('save', $this, 'changeTitle'); } protected function changeTitle($event) { $page = $event->arguments(0); $savedTitle = $page->get('title'); $t = wire()->templates->get($page->template); if($t == 'calender_item' && $page->is(Page::statusUnpublished)) { // if page is unpublished return; } else { $title = $page->get('title'); $date = wireDate('Y-m-d', $page->cal_start_date); $page->of(false); $page->title = $date.'-'.$title; $page->save('title'); $this->message("New saved title is {$page->title}"); } } Any help is welcome.
  5. Aha! That works. Thank you very much, a lifesaver
  6. Hi, thanks for your quick reply. I tried your option too, but it does not work (properly). If I tick the checkbox (tender_open field), it returns "<p>There are no tenders available!</p>" and if it's not ticked it returns nothing, just a title. Very strange. P.S. I was just playing with the $open as I don't know what to do anymore.
  7. Hi, this is probably very easy to solve but I just can get the right output. This is the code: <?php //$tender_open is checkbox field; $tenders = $pages->find("template=tender, sort=-created, tender_open=$open"); ?> <h3>Tenders</h3> <?php if($open == 0) { echo '<p>There are no tenders available !</p>'; } else { ?> <ul class="no-style"> <?php foreach ($tenders as $t) { ?> <li> <a href="<?php echo $t->url; ?>"><?php echo $t->title; ?></a> <br> <p>Status: <span class="open">Open</span></p> </li> <?php } ?> </ul> <?php } ?> This is the snippet from the homepage. The code should check if there is an open tender available, if true = display it and if false just output echo "There are no tenders available". Tenders are on separate page tree with their own template. I must be doing something wrong here! Help.
×
×
  • Create New...