Jump to content

qtguru

Members
  • Posts

    356
  • Joined

  • Last visited

  • Days Won

    5

Posts posted by qtguru

  1. 5 minutes ago, pwired said:

    Thanks for the examples guys. From here I can start trying out things. To let a website or a local computer (sometimes even a laptop) communicate with foreign databases is a much asked item. For example I know many call centers who are situated with local computers in Spain but want to fetch data from servers and databases in Germany.  Until know I lack how to code this but am learning bit by bit. This kind of work is payed very well if one knows how to do this.

     if you to make things easier, you can create an API sitting infront of the DB so from PW you simply call that API and based on the Data needed the API will fetch it from the relevant Database. However this might mean all call-centers having their own API so each can easily communicate because I doubt it would be easy to connect to their DB remotely directly. 

    • Like 3
  2. 6 minutes ago, ferdinand said:

    Yes I think  I'm beginning to undertstand. Correct to say that I add a general property courseData to all the page objects and whenever that is read I call my function to provide the data? And using the $event->object->name property I can retrieve the name of the calling page and return data specific to the url?

    That would work. And yet it makes you wonder, why there is not page_load_data field_load_data hook in pw. Any ideas why that is so?

     

    Not really, what the addHookProperty does is to run that code and inject your data from the database into Page::courseData in TLDR it dynamically creates the courseData property in the Page class. 

    • Like 1

  3.  

    13 minutes ago, adrian said:

    You can add a hook like this in your /site/init.php file:

    
    $this->wire()->addHookProperty('Page::courseData', null, function($event) {
        $sql = "SELECT * FROM ......";
        $results = $this->wire('database')->query($sql);
        $event->return = $results->fetchAll();
    });

    And then in your template file you can call: $page->courseData

    You can also make of $event->object->name inside the hook to get the name of the page that the courseData property is called from so you can use that in your sql query. Of course you can get any other field from the page, like $event->object->myfieldname and use that in your query as well.

    Does that help?

    Yep this works. Though once a cache is in place for that DB call there, I can say this seems like the solution and satisfies what OP needs. 

  4. If I am to get this straight you are looking to have Processwire render a page but the details are not coming the PW Database, it's trying to set data to PW instance during runtime, making it seem like it's serving from a page. 

    Indeed this is quite odd. Am curious why ?

     

     

     

  5. 11 hours ago, Wanze said:

    I'm sorry I will delete the post above, somehow I'm not able to write when editing and the posting was by mistake ???

    I don't understand your question, could you post some example code and explain in more detail what's the problem? The module should only attempt to render your page with smarty, if there exists a "myTemplate.tpl" smarty template to the corresponding "myTemplate.php" ProcessWire template.

    This is so awkward, The issue was sorted out but i actually forgot to reply to this forum as i didn't get any notification. thanks 

    • Like 1
  6. Hi I noticed during development of Modules, if i attempt to use Process::setViewFile it calls the current TemplateFactoryEngine which in my case is the Smarty Engine and attempts to look for a view in the site, I want to create modules with external templates rather than having templates in the code. I want to ask if there's a current way to stop this action. I will research and find out but i won't mind pointers thanks. 

  7. This is the main layout where other sub templates will be injected into

    plain.tpl

    <div class="header-container" id="header-container">
    
    <!-- Site navigation -->
      {include '../elements/nav.tpl'}
    
      <!-- The title of the site -->
    
    
    </div>
    
          <div class="wrapper">
            <div class="page-content">
              <div class="post">
    
      <header class="post-header">
        <h1 class="post-title">{$page->title}</h1>
        <p class="post-meta">{$page->published|date_format:"%A, %e %B %Y"}</p>
      </header>
    
      <!-- Beginning Twitter sharing Large button -->
      <a class="twitter-share-button" href="https://twitter.com/share"
      data-related="twitterdev"
      data-size="large"
      data-count="horizontal">
      Tweet
      </a>
      <!-- End of Twitter sharing button -->
    
      <article class="post-content">
        {block name="content"}{/block}
    
      </article>
    
      <hr>

    Notice the block name "content" assuming a visitor navigates to my about page here is the file for the about view

    about.tpl


     

    {extends '../layout/plain.tpl'}
    
    {block name="content"}
        
                              
                               {$page->body}
                               
                           
    {/block}

    See how clean and easy it is
     

    • Like 1
  8. 1 hour ago, adrian said:

    This ancient PR (https://github.com/ryancramerdesign/ProcessWire/pull/954/files?w=1) makes several changes to the comment field for logged in users, including using local profile image, and hiding (and autofilling)  the name and the email field.

    I know it doesn't really help you, but does let you know that others have similar needs :)

    I should maybe resubmit the PR to the new Github repo.

    Thanks already altered the core code, but i am going to inform the client that disadvantage of not taking emails... really requests like this make me want to quit frontend and do Backend totally. 

    • Like 1
  9. 11 hours ago, WinnieB said:

    Would you mind discussing what RBAC/Permissions features Yii2/Laravel have that ProcessWire doesn't?  Is it text-based configs, console tools, pre-made modules/API features, or something else?

    Not familiar with Laravel that much but I will talk on Yii2, Yii2 has a class responsible for adding Roles and Permissions, the roles are stored in the Database and there's a console tool to aid in creating of Roles, however how it works in Yii2 is that you create roles , create permissions, and you can also create more complex roles system in a way that goes like this

    Younglinh -> Padawan -> Jedi Knight -> Jedi Master with each higher roles having the existing permissions of the lower role, and when creating a user all you simply do is assign a user to a role, to use it, you simple check the users role and also infer if the user has permission to access that resource.

    http://www.yiiframework.com/doc-2.0/guide-security-authorization.html#access-control-filter you will see how it's implemented here. However since Processwire works with composer easily, there should be package around this. 

    • Like 1
  10. This will be my honest opinion

    3 hours ago, DL7 said:

    Basic website (showing all jobopenings on the homepage, specific jobopening page, Company page, search) {Should all be possible with PW without custom coding}

    Processwire works for this without a problem

     

    3 hours ago, DL7 said:

    - Company dashboard -> Login, Post openings, edit openings, edit company page, edit company profile, Check invoicing, Manage applicants {Login should be possible and editing should be possible without custom coding, I`m not sure about the management of applicant however. }

    - Management of applicants (Applicants can apply on the website. The information gets stored and company can see all the details. Company should be able to define the formfield wich they want to capture; manage the applicants (send emails, changes statuses)

    To be sincere this section I would advise using a framework like Yii2 or Laravel, if you are going to handle concepts like RBAC or Permission and authorization, as am assuming there would different roles and all. I tend to use Processwire for mostly content centric sites or mostly site management, but when it comes to applications with specific logic, I tend to use frameworks like Yii2/Symfony as i would love to have things as flexible as possible. 

     

    Once again this is my personal opinion. 

    • Like 1
  11. This looks awesome, well I don't think we should limited to 1 Module, different modules might have things that don't appeal to you, with that being said, This will benefit me because I am behind a Firewall at the office, so it's hard to FTP in my site. 

    • Like 1
  12. 7 hours ago, teppo said:

    That being said, when I browse the list of the most popular packages on Packagist, I see some projects I've used in the past (using a basic download / git clone + require one file approach) and some that I probably could've used but usually have worked around with a few lines of my own code

    True you do have a point, Composer is just another means 

    • Like 2
  13. On 9/23/2016 at 8:22 PM, szabesz said:

    To tell the truth, I've just copied it over from Ryan's blog post without thinking too much... Probably that is why the "Composer method" of installing is not yet "promoted". I'm not a Composer user, but it would be interesting to see what the recommended way of setting up a site and using Composer at the same time is. A tutorial for Composer newbies like me would be nice.

    wow why don't you use Composer, it's really a must-use tool esp for resolve dependency in PHP world

×
×
  • Create New...