Jump to content

Hari KT

Members
  • Posts

    126
  • Joined

  • Last visited

Posts posted by Hari KT

  1. Piwik is awesome to track. I have installed piwik 1.0 and did something before for a project.

    For the current project I am also trying 2.0, which is far better. I can see various use cases with it.

    One of the good thing is you can call the piwik api, get the image or json and plot or change accordingly on our system.

    Update : If you don't have a server to manage or install piwik then will be good to go with google analytics. And in 2.0 installation, I didn't have any trouble also.

    • Like 3
  2. Hi Soma,  Martjin,

    Let me make the question more clear with the examples you mentioned.

    We have Categories->Products ( x1, x2, x3, x4, x5, x6 )

    Let us assume the user saves products in the order x4, x1 .

    Now in the user template we have a field with user_product which is multi page array whose template is product. So when the user save the first one we need to track the time when the product is added.

    $user->user_product->add($product1); // May be id or page object
    
    // Now we need to know when the product1 is added
    

    That means we need an extra field for the user to know at what time the product is saved, else we will not be able to keep track of the order in which the user has saved.

  3. Hi Guys,

    I am looking for the best way what you feel when doing this. Basically the idea is to save the history of a user.

    Consider we have a bunch of products, and categories. And the user needs a way to save a product and check it for later use. Consider the same as you follow a topic in the PW forum.

    I was thinking to add a page which have 2 fields

    1 ) user_id which is of type Page which is linked to the user template of PW 

    2 ) product_id which is also a Page which I have built from another template

    I have removed the global title, but it needs the url always entered.

    $page = new Page();
    $page->template = 'product-history-user';
    $page->parent_id = 'parent-id';
    $page->name = 'something';
    $page->history_user_id = $user->id;
    $page->user_history_product_id = 'id-of-product';
    $page->save();
    

    I also have some more stuffs that needs similar logic. Interested to hear your thoughts to make this better.

    Update :

    One more problem I missed to write is, I need to sort it based on the priority, that is why I opted the way.

    or is there a way we can store the date and time of the product when saved?

    Thanks

  4. Hi Guys,

    I have a $field->type instanceof FieldtypePage .

    I want to know the template of the FieldtypePage .

    I have tried

    $template = $this->pages->get($field->parent_id)->template;
    

    I am getting a different template than the one I really need.

    $fieldpage = new Page();
    // $fieldpage->template = $name;
    
    // Is there something like without assigning template name I can save a page ?
    
    // $fieldpage->template_id = $template_id
    $fieldpage->title = 'title';
    $fieldpage->body = 'body';
    $fieldpage->parent_id = $field->parent_id;
    $fieldpage->save();
    
  5. Hi,

    I have send a PR to https://github.com/ryancramerdesign/ProcessExportProfile/pull/3 .

    If you have a private repo or you find a repo which has no composer.json , you can send a PR. And for the current time you can do like below

    {
        "minimum-stability": "dev",
        "repositories": [
            {
                "type": "package",
                "package": {
                    "name": "ryancramerdesign/process-export-profile",
                    "version": "1.0.0",
                    "source": {
                        "url": "https://github.com/ryancramerdesign/ProcessExportProfile",
                        "type": "git",
                        "reference": "master"
                    },
                    "type": "pw-module",
                    "require": {
                        "hari/pw-module": "dev-master"
                    }
                }
            }
        ],    
        "require": {
            "ryancramerdesign/process-export-profile": "1.0.0"
        }
    }
    

    and now you need composer.phar . Hope you have downloaded composer else please get from http://getcomposer.org/download/ and run

    php composer.phar update
    

    It will install the ProcessExportProfile module in site/modules/ProcessExportProfile . When you created a patch for the module, you can change the settings in composer.json , so you get that patch also until Ryan merged it or can switch between branches. See http://getcomposer.org/doc/05-repositories.md#loading-a-package-from-a-vcs-repository

    Thank you.

    • Like 3
  6. Hi guys,

    so I am a huge fan of composer. PW is missing one of the good parts of composer. So here is a new installer to install the modules of PW via composer.

    If you have created a module for PW, what you need to do is add a composer.json file in your github repo and add it to packagist. An example composer.json is

    {
        "name": "vendor/package-name",
        "type": "pw-module",
        "description": "Your module what it does",
        "keywords": [ "keywords", "comma", "seprated"],
        "homepage": "https://github.com/harikt/Assets",
        "license": "BSD-2-Clause",
        "authors": [
            {
                "name": "Assets Contributors",
                "homepage": "https://github.com/harikt/Assets/contributors"
            }
        ],
        "require": {
            "php": ">=5.3.0",
            "hari/pw-module": "dev-master"
        }
    }
    

    Note the minimum requirement is PHP 5.3 for composer is 5.3 .

    An example of a module that works with this is https://github.com/harikt/Assets ( Move the index.php to any where :-) )  You are welcome to read the post at http://harikt.com/blog/2013/11/08/assets-for-processwire/

    Installing modules

    How do you install the PW modules and the 3rd party dependencies ?

    Assuming you are in the PW folder.

    First download composer from http://getcomposer.org/download/.

    Hope you have composer.phar now.

    php composer.phar require vendor/package-name
    

    Will install if the vendor/package-name is of type "pw-module" and you have added the "hari/pw-module" in require section.

    {
        "name": "vendor/package-name",
        // more stuffs
        "type": "pw-module",
        "require": {
            "php": ">=5.3.0",
            "hari/pw-module": "dev-master"
        }
    }
    

    to `site/modules/PackageName` .

    php composer.phar require hari/assets
    

    Try the above and see where it is installed.

    Please add a composer.json if you are a module maintainer, for there is more things we can do with composer ;) .

    • Like 4
  7. Hi guys,

    I am really new to here and I would have missed many posts. I have read there is a thought to look at composer and also switching to PDO .

    I am happy to help in the PW development. But I am not sure where we are at present. I would like to add a module so people can still install in site/modules folder.

    Though in composer world people don't like that, let me know how you are going to download the modules ?

    Is it inside `vendor` or is it inside `site/modules` as the current PW is doing ? I am happy to contribute a module for PW to support composer usage. ( Happy to hear your thoughts for if you already started then I don't need to re-invent anything here )

    If composer a small recommendation about the PDO and usage :

    I have a bit of background in aura, so you should really have a look at  https://github.com/auraphp/Aura.Sql/tree/develop-2 . The ExtendedPdo is lazy loaded https://github.com/auraphp/Aura.Sql/tree/develop-2#lazy-connection .

    Also the IN ( usage is also simple https://github.com/auraphp/Aura.Sql/tree/develop-2#array-quoting

  8. Yey, nice time to get involved in ProcessWire. I have been looking at Processwire for a recent project. It is really nice from a user perspective hiding all the complex functionalities. Amazing work guys. I don't say you move to use this or that ( Though I am more inclined towards Aura ;) ).

    Composer is really a nice tool, and when we go with composer and you install it is always good to keep the files in vendor folder itself. Some of the things in my mind are

    1. Flexibility to move the index.php to outside the main folder. So only index.php is the only file lies there.

    else vendor folder will be visible to the public . May be readmes and all .

    2. When working on aura v1 , we installed the packages in the package folder itself. But that is a hard way to manage. So we started with http://github.com/auraphp/Aura.Includer/

    So it will be nice to have something like adding a certain configuration file in the module of PW which helps to recognise the file is processwires and which needs to be loaded via same ?

    Also does the 2.4 development is finished ? There is PSR-4 also coming, which reduces the size of the namespace stuffs.

    \ProcessWire\Event\Manager => src/Manager.php ( PSR-4 ) than the previous one /src/ProcessWire/Event/Manager.php

    I am looking forward to contribute to PW aslo please choose PSR-2 also. It is all about future and how we all PHP community work ( For I contribute to Aura, Symfony, Zend etc life is easy ) .

    Thanks

    • Like 1
  9. Thanks @Wanze .

    So to make it clear, what I am doing is moving the index.php to a seprate folder.

    Say

    site
    wire
        web
            index.php
    
    

    So the problem we are going to face is none of the images, js, css cannot be accessed.

    A good example is call for http://processwire.localhost/site/templates/styles/main.css will result in 404 , for the only entry point is index.php . I can create symbolic links, but I thought of making a module ;) . So my goal is to create a module which can check whether the request is for a certain type ( css, image, js ) and return the content according to the type. (I have already created the same.)

    About the usage of $_SERVER seems a bad idea to me as I mentioned earlier. If some ( 3rd party module ) replaces the content, hard to deal.

    For those who don't know me, I have a bit of background in aura project ( and some other open-source projects ) and you can see the how the $_SERVER is accessed. Once you set, even if someone resets the superglobals the object value never changes.

    Let me show you an example from aura v2

    <?php
    use Aura\Web\WebFactory;
    
    $web_factory = new WebFactory($GLOBALS);
    $request = $web_factory->newRequest();
    echo " Request uri is " . $request->server->get('REQUEST_URI');
    $_SERVER['REQUEST_URI'] = 'oye I am changing';
    echo $_SERVER['REQUEST_URI'] . PHP_EOL;
    echo $request_uri = $request->server->get('REQUEST_URI', '');
    

    If you have tried the above example you will understand what I mean. ( I am not promoting aura here, my goal is to make PW things better and secure. I am also going to search for the thread composer and how it is utilized )

    If anyone is interested have a look into the links below

    https://github.com/auraphp/Aura.Web/blob/develop-2/README-REQUEST.md#superglobals

    https://github.com/auraphp/Aura.Web/blob/develop-2/src/Request.php#L162

    https://github.com/auraphp/Aura.Web/blob/develop-2/src/Request/Globals.php#L99

    https://github.com/auraphp/Aura.Web/blob/develop-2/src/Request/Values.php#L36

    Thank you.

  10. Thank you @Michael.

    No I wasn't looking how I can iterate through the server variables.  According to what I learned using global values inside the class seems not a good way, so was wondering whether the post values, what sort of REQUEST_METHOD is already called is available via some objects which is called in bootstrap.

    You can have a test to the code below to see what I mean

    var_dump($_SERVER);
    // see how the o/p differs
    $_SERVER = array();
    var_dump($_SERVER);
    

    That becomes a hell to all if someone set like this in a module.

×
×
  • Create New...