Giter Site home page Giter Site logo

Usage / rebuild getResources about pdotools HOT 6 CLOSED

modx-pro avatar modx-pro commented on September 3, 2024
Usage / rebuild getResources

from pdotools.

Comments (6)

bezumkin avatar bezumkin commented on September 3, 2024

You can try to use msProducts as replacement for getResources.

Later i want to include this functionality in pdoTools.

from pdotools.

bezumkin avatar bezumkin commented on September 3, 2024

By the way, here is possible config options.
You can look in methods, how they used in class.

I have documentation for pdoTools, but it on russian and availible only for my paid subscribers.

from pdotools.

exside avatar exside commented on September 3, 2024

Hi,

thanks for the reply, tried a bit around with some additional config options and was a bit more successful (at least getting the resources in an array and can do something with them, not much yet, but better than nothing=D)

Would love to pay that 300 rubels to get more info about pdoTools, I have signed in, but cannot make that payment because google has troubles translating the pages when I'm logged + z-payment/qiwi dont let me do anything (z-payment bc russian only and qiwi because switzerland ist not on the supported country list). Any possibility that I pay the 300 rubles per paypal and can somehow access that pdoTools documentation / that article here Самые быстрые сниппеты с pdoTools http://bezumkin.ru/sections/php/556/

I have the following now:

<?php
$pdoFetch = $modx->getService('pdofetch','pdoFetch', MODX_CORE_PATH.'components/pdotools/model/pdotools/');

if ( $pdoFetch instanceof pdoFetch ) {
    $pdoFetch->config['tpl'] = 'article.teaser';
    $pdoFetch->config['return'] = 'data'; // this was necessary to get back an array
    $pdoFetch->config['fastMode'] = 1; // doesn't matter if I put 0 or 1 there, the placeholders with output filters don't get processed
    $pdoFetch->config['includeTVs'] = 1; // maybe related, but I don't see any tv data if I print_r the single resources
    //$pdoFetch->config['includeTVList'] = 'article.teaser.title,article.teaser.img,article.img.full,team-img,team-job'; // this gives me some sql syntax error
    //$pdoFetch->config['tvsSelect'] = array('article.teaser.title'); // same here
    echo '<pre>' . print_r($pdoFetch->config,1) . '</pre>';

    $rows = $pdoFetch->run();

    if (!empty($rows) && is_array($rows)) {
        //echo 'rows is array';
        foreach ($rows as $row) {
            //echo '<pre>' . print_r($row,1) . '</pre>';
            echo $pdoFetch->getChunk($pdoFetch->config['tpl']);
            //echo $row['pagetitle'];
            //var_dump($row);
        }
    }
//var_dump($rows);
}

and the tpl chunk is:

<article class="col teaser">
    <section class="teaserwrap">
        <figure>
            [[+article.teaser.img:isnot=``:then=`<img src="[[+article.teaser.img]]" alt="" />`:else=`[[+article.img.full:isnotempty=`<img src="[[+article.img.full]]" alt="" />`]][[+team-img:isnotempty=`<img src="[[+team-img]]" alt="" />`]]`]]
            <figcaption class="hoverlay border-box">

            </figcaption>
        </figure>
        <hgroup>
            <h3><a href="[[~[[+id]]]]" class="biggie">[[+article.teaser.title:default=`[[+pagetitle:limit=`44`]]`]]</a></h3>
            <h6 class="claim">[[+article.teaser.claim:default=`[[+longtitle:isnotempty=`[[+longtitle:limit=`26`]]`]][[+team-job:isnotempty=`[[+team-job:limit=`26`]]`]]`]]</h6>
        </hgroup>
    </section>
</article>

this gives me just output like this:

[[+article.teaser.img:isnot=``:then=``:else=`[[+article.img.full:isnotempty=``]][[+team-img:isnotempty=``]]`]]
[[+article.teaser.title:default=`[[+pagetitle:limit=`44`]]`]]
[[+article.teaser.claim:default=`[[+longtitle:isnotempty=`[[+longtitle:limit=`26`]]`]][[+team-job:isnotempty=`[[+team-job:limit=`26`]]`]]`]]

so the 2 main question are:

  1. how do I include TV's correctly so they can be parsed by getChunk()

and

  1. if not with fastMode=1or 0, how to get pdoFetch to parse placeholders with output filters?

from pdotools.

bezumkin avatar bezumkin commented on September 3, 2024

You do not send data to getChunk!

    if (!empty($rows) && is_array($rows)) {
        foreach ($rows as $row) {
            //echo '<pre>'; print_r($row); die; // this will print the whole fields of row and exit
            echo $pdoFetch->getChunk($pdoFetch->config['tpl'], $row); // You forgot to send $row into the method
        }
    }

If you want, you can manually send me $10 to PayPal ([email protected]), then send a letter (with your credentials on my site) and i will open access to your account for a month.

  1. TVs including by
&includeTVs=`tvname,othertvname,etc`.

Also you can use &tvPrefix=, it is blank by default.

  1. Fast mode will cut all unprocessed placeholders with filters. It is need only if you receive all needed data from tables and prepare it manually. And it works very fast, becouse do not use tags processing.

from pdotools.

exside avatar exside commented on September 3, 2024

Hi,

thanks again for the response! Just sent you the 10$ via paypal!

tried your suggestion with includeTVs but wasn't successful, could i t be a problem to have dots (.) in tv names somehow? Because I get

[pdoTools] Error 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.contentid=modResource.id AND TVarticle.img.full.tmplvarid=17 LEFT JOIN `modx_si' at line 1

when I run this in Console

<?php
$pdoFetch = $modx->getService('pdofetch','pdoFetch', MODX_CORE_PATH.'components/pdotools/model/pdotools/');

if ( $pdoFetch instanceof pdoFetch ) {
    $pdoFetch->config['tpl'] = 'article.teaser';
    $pdoFetch->config['return'] = 'data'; // this was necessary to get back an array
    $pdoFetch->config['fastMode'] = 0; // doesn't matter if I put 0 or 1 there, the placeholders with output filters don't get processed
    $pdoFetch->config['includeTVs'] = 'article.teaser.title,article.teaser.img,article.img.full,team-img,team-job'; // maybe related, but I don't see any tv data if I print_r the single resources
    //$pdoFetch->config['includeTVList'] = 'team-img,team-job'; // this gives me some sql syntax error
    //$pdoFetch->config['tvsSelect'] = array('article.teaser.title'); // same here
    echo '<pre>' . print_r($pdoFetch->config,1) . '</pre>';

    $rows = $pdoFetch->run();

    if (!empty($rows) && is_array($rows)) {
        //echo 'rows is array';
        foreach ($rows as $row) {
            //echo '<pre>' . print_r($row,1) . '</pre>';
            echo $pdoFetch->getChunk($pdoFetch->config['tpl'], $row);
            //echo $row['pagetitle'];
            //var_dump($row);
        }
    }
//var_dump($rows);
}

and if I remove the TVs with dots in their names (leaving just team-img and team-job) I get this error

[pdoTools] Error 42S22: Unknown column 'TVteam' in 'on clause'

from pdotools.

bezumkin avatar bezumkin commented on September 3, 2024

Of course, remove the point, they break SQL query.

Access granted. Please, write me futher comments on my site.

from pdotools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.