Jump to content

flydev

Members
  • Posts

    1,327
  • Joined

  • Last visited

  • Days Won

    47

Posts posted by flydev

  1. Ok, I think I got what you mean. Yes it will be reset to 0. Just forget what I said before.

    Instead of having $session->set('count', 0) in your template, set it in _init.php :

    if(!$config->ajax) $session->set('count', 0);

    So, if you refresh the page, the $session->count will be reset to 0, if the page is called by AJAX then $session->count is incremented.

     

    all-services.gif.23dc63ebd9e5f797d0f0c94a694e705b.gif

     

    • Like 3
  2. Keep in mind that there a are other better ways to achieve this. You should read this tutorial made by @kongondo

     

    Anyway, to continue with the repeater and to add tags to your aforisms you could create a new template "aforisms_tags" and a page in the PageTree called "Aforisms Tags", assign the template "aforisms_tags" to this new page; And add some children to this page: tag1, tag2, tag3...

    Then you create a new field of type PageReference , set the option Input Field Type to "AsmSelect" and set the option Parent to the new created page "Aforisms Tags". Then you add the field to your "aforisms_repeater".

    Illustration :

    58abe64200d7e_Capturedecran2017-02-21a08_03_12.png.1cd7d1578beabe3c209e1d568b009ef7.png                      58abe5cae5899_Capturedecran2017-02-21a07_57_11.thumb.png.271426935dee81492698a5a2a1ad92ae.png

     

    There is the code :

    $aphorisms_list = '';
    $tags = '';
    foreach($page->aforisms_repeater as $aforism)
    {
        $aphorisms_list .= "<li>";
        $aphorisms_list .= $aforism->aforisms_title;
    
        foreach ($aforism->aforisms_tags as $tag) {
            $tags .= "<span class='tag' style='margin: 3px; color: red;'>";
            $tags .= $tag->title;
            $tags .= '</span>';
        }
        $aphorisms_list .= "{$tags}</li>";
    }
    
    $content .= "<ol>{$aphorisms_list}</ol>";

     

    • Like 2
  3. 19 hours ago, Cengiz Deniz said:

    Every aphorism should have one or more topics fields. Is it possible ?

    Surely, but I don't get what you mean by one or more topics fields, could you explain a bit further whats your needs and/or show us what you already tried ?

     

    Maybe are you talking having an aphorism with a reference to a page in the PageTree ?

  4. Welcome to the forum @Cengiz Deniz

     

    About your question, you could use a Repeater for the aphorisms in your template.

    First read this doc :  http://processwire.com/api/fieldtypes/repeaters/ ,  you should get an idea on how repeaters works.

     

    So for your example, you could make a new text field called aphorism_title and a new repeater called aphorism_repeater. Finally you add the text field 'aphorism_title' to the repeater. You should end up with something like that :

    Capture.PNG.6aa33b7604165bd60d771e04c254c1ff.PNG

     

    In your page template, you add the repeater field you just created, and add some aphorism to it :

    Capture.thumb.PNG.9301b18045190ebb3e2a36bc1734202f.PNG

     

    Then in the template code, a simple foreach loop will do the job to show all the aphorisms in a list:

    <h3>ÖzlüSözleri</h3>
    <?php
         $aphorisms_list = '';
         foreach($page->aphorism_repeater as $aphorism) 
         {
              $aphorisms_list .= "<li>{$aphorism->aphorism_title}</li>"    
         }
         
    ?>
    <ol>
    <?php echo $aphorisms_list; ?>
    </ol>  

     

    Hope its clear enough, you can adapt it depending the output strategy you use, but do not hesitate to ask more information.

    Good luck!

     

     

    • Like 5
  5. Hi @MaryMatlow

    15 hours ago, MaryMatlow said:

    I've installed it and it works fine.

    Can you please tell me the version of ProcessWire ?

     

    15 hours ago, MaryMatlow said:

    Is there a way to add heading and link to the images?

    Yes, you have to copy and/or modify the function bsRenderCarousel();

    For instance, you could use a repeater to pass datas to the function. Let's say we create a repeater with the three following fields: image_carousel, heading, heading_description

    Capture.PNG

    and insert the repeater with the name 'carousel' in the home template.

     

    In _func.php, add this function :

    Spoiler
    
    function bsRenderCarouselFromArray(array $datas) {
    
        $cnt = count($datas['images']);
        $id = $datas['images'][0]->get('page').$datas['images'][0]->get('field')->id;
        $out  = "<div id='carousel-{$id}' class='carousel slide' data-ride='carousel'>
                    <ol class='carousel-indicators hidden-sm-down'>";
        $i = 0;
        foreach($datas as $image) {
            $class = ($i == 0) ? "active" : "";
            $out .= "<li data-target='#carousel-{$id}' data-slide-to='{$i}' class='{$class}'></li>";
            $i++;
            if($i >= $cnt) break;
        }
        $out .= "</ol>
                 <div class='carousel-inner' role='listbox'>";
        $i = 0;
    
        foreach($datas as $data) {
            $class = ($i == 0) ? "active" : "";
            $out .= "<div class='carousel-item $class'>
                    <img src='{$datas['images'][$i]->url}' alt='{$datas['images'][$i]->description}' height='{$datas['images'][$i]->height}' width='{$datas['images'][$i]->width}'>
                    <div class='carousel-caption'>
                        <h3>{$datas['headings'][$i]}</h3>
                        <p>{$datas['description'][$i]}</p>
                    </div>
                 </div>";
            $i++;
            if($i >= $cnt) break;
        }
        $out .= "</div>";
        $out .= "<a class='left carousel-control' href='#carousel-{$id}' role='button' data-slide='prev'>
                    <span class='icon-prev' aria-hidden='true'></span>
                    <span class='sr-only'>Previous</span>
                 </a>
                 <a class='right carousel-control' href='#carousel-{$id}' role='button' data-slide='next'>
                    <span class='icon-next fa fa-chevron-right ' aria-hidden='true'></span>
                    <span class='sr-only'>Next</span>
                </a>
            </div>";
    
        return $out;
    }

    a bit hacky but eh...

     

    Then in the home template, make the array and call the new function with the new array as parameter :

    // render the carousel
    //$content .= bsRenderCarousel($page->images);
    foreach ($page->carousel as $key => $value) {
        $datas['images'][] = $value->carousel_image;
        $datas['headings'][] = $value->heading;
        $datas['description'][] = $value->heading_description;
    }
    
    $content .= bsRenderCarouselFromArray($datas);

     

    Result:

    pwbs4.gif

     

     

    • Like 4
  6. 9 hours ago, fbg13 said:

    @flydev Take a look at https://github.com/jubos/fake-s3 and https://github.com/jserver/mock-s3

    I have not used them.

    It is mainly to test different servers configuration as currently the AmazonS3 implementation is quite stable. And I found a way directly in the AmazonAWS console to create accounts and sharing keys for users.

    Anyway thanks for the suggestion, maybe I will give  a try by curiosity ;)

    • Like 1
  7. How to create a GoogleDrive service account step-by-step

    Edited the 2017-02-18

     

    Go to https://console.developers.google.com

     

    • Create a new project:

    step1.PNG

    step2.PNG

     

    • Enable the API:
       

    step3.PNG

    step4.PNG

    step5.PNG

     

    • Create credentials:


    step6.PNG

     

    • Select "New service account"

    step7.PNG

    step8.PNG

     

    • Click on Create and save the JSON key file
    • Click on Manage service accounts :

    step9.PNG

     

    • Copy the service account ID :

    step10.PNG

     

    • Configure Duplicator by copy/pasting the service account's email and the content of the JSON key file :

    step11.PNG

     

    • Like 4
  8. In before complete answer, the first thing I see is :

    12 minutes ago, Marc said:

    By upgrading to PW 3 I mean I did the standard upgrade path by overwriting the wire folder, index and htaccess files

    What the doc say:

    When you put in the new /wire/ directory, make sure that you remove or rename the old one first. If you just copy or FTP changed files into the existing /wire/ directory, you will end up with both old and new files, which will cause an error.

  9. 21 hours ago, modifiedcontent said:

    But the result is fatal server errors and pages that can't be found. So my question was very specific; has anyone successfully installed Processwire on AWS?

    Yes. And the setup is :

    • Ubuntu 16.04
    • Apache 2.4.18
    • MySQL 10.0.29-MariaDB
    • PHP-7
    • ProcessWire 3.0.52

     

    21 hours ago, modifiedcontent said:

    Login to Admin gives me a 404 Not Found; 'The requested URL /admin/ was not found on this server'.

    add this directive to your VirtualHost in /etc/apache2/sites-available/000-default.conf :

    <Directory /var/www/>
         Options Indexes FollowSymLinks
         AllowOverride All
         Require all granted
    </Directory>
    

     

    • Like 2
  10. 11 minutes ago, suntrop said:

    Anybody knows that problem? Or what to do?

    Just for informations - on my test installation, your dump is imported successfully.

    • Apache/2.4.23 (Win64) PHP/5.6.25
    • libmysql - mysqlnd 5.0.11-dev - 20120503
    • Extension PHP : mysqliDocumentation curlDocumentation mbstringDocumentation
    • Version PHP : 5.6.25
    • Version MySQL : 5.7.14
    • Version PHPMyAdmin :  4.6.4
    • Like 1
  11. Can't found the answer on the IPB doc.

    Is there a limit to the number of participants in a private conversation ? Look like 5 is the max.

     

    Another little thing about the "module tag" in modules forum, its width is huge :

    modules-tag.png

    Nothing really annoying but every day I wonder if this is normal, as every module does not contains the tag, and if it was the case, this will be 'huge' imo.

    • Like 1
  12. Mmm the module itself will be, but updating the SDKs with ProcessWireUpgrade (if that what you mean) will be hard if I am not missing something with this module.

    What I am thinking after some tests, and in particular about shared hosting,  its to put on Github the vendor directory and let the user download and upload it to the their server if they want to use third party service storage. This approach only work (as the module itself) for ProcessWire 2.8 and 3.x. And if some people want simplicity on their virtual/private server, they just have to run a simple command line - composer update - in the root directory. Really, composer is nothing more than a tool to manage dependencies, and installing/using it require only one command line or a simple exe setup on Windows.

    Anyway, I will try to find a compromise and/or to figure how to manage theses dependencies in the module directory itself. If I can manage this, the module will be compatible with ProcessWire 2.7.

    • Like 4
  13. A small news for this morning, the AmazonS3 feature is implemented on the module (its a pain when you don't know about a SDK).

    Also please check the name of the final package as it was suggested by @szabesz.  Thanks again for the suggestion, its better and easily manageable.

     

    Edit:

    For information, all SDKs are installed via composer. Is it a problem for you ?

     

    duplicator-preview.gif

     

     

     

    • Like 6
    • Thanks 1
  14. 11 hours ago, Lance O. said:

    [...]

    if ( $session->login($input->post->user, $input->post->pass) ) {

    [...]

    The login function returns an user object on successful login or null on failure. 

    You need to check this returned user object for roles:

    [...]
    
    $loggeduser = $session->login($input->post->user, $input->post->pass);
    if ( $loggeduser->isLoggedIn() ) {
    	// user was authenticated and logged in
    	// user has "admin" or "superuser" role
    	foreach ($loggeduser->roles as $role) {
    		$content .= $role->name . "<br/>";
    	}
    }
    
    [...]

     

    PS: do not forget to sanitize your input.

    • Like 5
×
×
  • Create New...