Jump to content

virtualgadjo

Members
  • Posts

    231
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by virtualgadjo

  1. @Robin S no i checked, this of course before my test choosing a published speaker assigned to a published debate (both not hidden of course too)

    but thanks for the info, as you say, this is not intuitive and is probably going to help me for other kind of selections within the debates (which day, days are in a select, main theme, and so on) and i have a lot to come...
    even less intuitive when printing the deb_inters field this should be searching through

    print_r($pages->get(1071)->deb_inters);
    // returns
    ProcessWire\PageArray Object ( [count] => 2 [items] => Array ( [Page:0] => Array ( [id] => 1076 [name] =>.....),
    [Page:1] => Array ( [id] => 1156 [name] =>...)
    // i spare you the full result which is quite a thing and you know that better than me :)

    thanks again for your help and letting me know something new for me!

    have a nice day

  2. Hi @Robin S

    and thanks a lot for taking time to read my silly prose ?

    unfortunately, this doesn't work, probably becaouse it is a multiple page field type and containing an array even if only one element
    a foreach later, my query return

    Array ( [0] => 1071 )  // the page of the debate this guy is assigned to

    your solution (using $page as well as $page->id) returns

    ProcessWire\PageArray Object ( [count] => 0 [items] => Array ( ) [selectors] => template=adebate, deb_inters=1076 ) 

    thanks again for your help ?

    have a nice day

  3. Hi,

    i confess, i have very baaaad habits and being a db freak doens't help getting rid of them but i try hard, i swear ?

    so, i'm working on a website with around 60, say, debates
    there are around 200 speakers
    in each debate template there is a field (deb_inter) to assign its speakers, more often several than one then, as you can guess, the field is a multiple page reference field, so far, full pw ?

    now, on each speaker page i need to display the debate(s) he/she is assigned to and if i try something like this

    $pages->find('template=adebate, deb_inter*=' . $page->id);

    guess, i get an error saying that *= is not implemented for fieldtypepage, i knew it but i couldn't help trying once more... ?
    i've searched the docs once more (i think, i'll end knowing them by heart :)), searched the forum too but couldn't find a simple and pw way to do this, well say as simple as this

    $qi = $database->query("select pages_id from field_deb_inters where data = $page->id");

    which does exactly what i'm looking for (even if returning only pages id instead of a pw array), baaad habits, told you ?
    but, as i'd like to die a little less dumb every day, i'm wondering, is there a more pw way to do this kind of selection with pw selectors and for any kind of field containing a pw array instead of a string/number

    thanks in advance for your ideas helping an old guy getting a little less dumb ?

    have a nice day

  4. hi,

    just my two cents ?
    like @Gideon So says, the created on field in pw is called "created" (you can see this having a look at the bdd tables)
    something i often do when i need a peculiar sorting for a repeater is using this famous hook in the site ready.php file

    $this->addHookAfter('FieldtypeRepeater::wakeupValue', function($event) {
        $field = $event->arguments('field');
        if($field->name !== 'your_repeater_name') return; // in order to sort only a specific repeater
        $pa = $event->return;
        $pa->sort("sorting_field"); // the field you want the repeater to be sorted by
        $event->return = $pa;
    });

    this way, the repeater is also sorted the way you want in the admin

    in case it may help

    have a nice day

    • Like 1
  5. hi,

    even it's a funny idea as
    - you'll be multiplying duplicate contents between this latest-article and... the latest article
    - the content of this latest-article will change quite often
    it's quite easy to achive, just use $pages->find  with template and sort by -date (with your own field naming convention) to get the id of your latest article on top of the code and then use $pages->get(xxxx)->content and so on to display the latest article content/images/... in the page

    hope it helps

    have a nice day

    • Like 3
  6. Hi,

    of course

    if ($page->content3 != '') // this only checks if the field has content but assumes it exists

    supposes that there is a field named content3 in the page, if it's possible that not then an explicit

    if (isset($page->content3) && $page->content3 != '') //verbose version ?

    that's one of the reason why when using markup regions for a website that have very different pages i often use the probably common sections in the _main.php file and a mainwrapper... wrapping the various fields that are more page specific in the page templates
    this allows my _main.php to have a little less logics and be a little more readable ?

    have a nice day

  7. hi,

    two simple ways to do this

    - i assume your sections are inside a id="mainwrapper" (just for the example, use the id you linke ? ) div
    in your page specific templates you can just use the sections you need, done...

    - the other way is to simply put every section inside a php if

    <?php if ( $page->content3 != '' ): ?>
    <section class="content3">
      ...
    </section>
    <?php endif; ?>
      
      

    done ?

    have a nice day

  8. Hi,

    well, pw speaking, this is the simplest thing you can imagine ? actually, you won't need any module to realize what you describe, just page(s) and fields
    remember the pw way of thinking, everything is a page, so, just create a page upcoming dates which will have as many subpages you want, every subpage containing all the fields you need, date, title, description, tags, and so on, done

    you could even do the same thing with a simple page and a repeater field, each repeater element containing all those fields too, the only thing to keep in mind is the number of elements you'll need, if there is really a lot, maybe it will be faster to edit with subpage than with a repeater, if you're thinking about 20/50 upcoming dates, go for a repeater, everything will be in the upcoming dates page

    once you'll have done it, you won't believe how easy it was with pw ?

    have a nice day

  9. Hi,

    juste in case it would help, i nearly always add this maximize ability to ckeditor fields

    image.png.0508446f5f8b0711c3ed0bbadb41a267.png
    it adds a button to the field toolbar that allows you to write with a full screen field (very useful with heavy content pages...)
    you just have to go back to normal size to save but honestly, not really a problem
    image.png.093ef04fae1a39003b032a20057bebe1.png
    have a nice day

    • Like 2
  10. hi,

    this makes me going back to what i was thinking ?
    is your website installed in a folder on your server, is there a domain aiming to this folder, have you installed pw using your domain (if any) what automatically fills the config file with the right config urls

    this being said, have a look to the bottom of your config file looking for this var $config->httpHosts = array('...')
    when you look at it, is the url the one you use to preview you website, if not your problem is here ?

    i must say i never run into this kind of issue as i always write my css, js and so on paths myself without the php part /site/assets/css/...css
    but if your config file url is the good one, in the source code you should see the right path to your website domain/site/templates/styles/main.css

    in fact, have look at what is in the config.php array and compare it with the path in the source code, you'll probably find a "slight" difference ?
    (usually on install, pw, checks if the folders that need to be are wirtable, a path to those folders should not return a 403 (nor a 404 by the way :))

    have a nice day

  11. hi,

    honestly this kind of things is usually due to the path you've set to those css files (nothing to do with pw or not actually)
    a simple way for you to check, start emptying the cache (module page render) then look at the page source code and click on the css file link, you'll see if your run into a 404 or if you see the file source

    simple thing to take into account, this may depend on if you're working with a vhost/domain or juste pointing to your hosting root and if your links start with a root / or not

    hope it'll help

    haves a nice day

    • Like 1
  12. Hi,

    @Jan Romero is right, if you only want to calculate the difference between two years, the first solution will work but, if you want to calculate the number of years between a specific date and today, then, as easy to achieve with php but switch to date_create() and date_diff()
     

    <?php
    $start = date_create('1980-07-01');
    $today = date_create(date('Y-m-d'));
    $diff = (array) date_diff($today, $start);
    
    echo $diff['y'];

    the result will change every 1rst of July, a simple way to calculate an age and not only the difference between two years
    just print_r($diff) if you want to see how far you can go with what you get and could display with date_diff ?

    have a nice day

    • Like 3
  13. well if you want a dynamic code depending on an entry, yes you will ?
    your hanna code tag could accept either [[count_years]] or [[count_year startyear="1920"]]

    in this case you can just start your hannacode with a default value

    $start = $startyear != '' ?  $startyear : 1980;

    this way you cover both insertion, with and without attribute

    and my pleasure ?

    have a nice day

    • Like 2
  14. hi,

    honestly, hard to answer without seeing the whole page source code but you can bet that when this kind of thing happens you have somewhere either an unclosed tag (hence the whole page source code) or, and it happens more often than you could imagine, something like two body tags ("like" because it happens with a few other important tags too)
    just an example of when this kind of thing happens, using markupregions and forgetting an html head in another template than the _main.php => two html head and opening bodies => a little mess ?

    hope it may help looking for the issue origin

    have a nice day

    • Like 2
×
×
  • Create New...