Jump to content

Frank Vèssia

Members
  • Posts

    584
  • Joined

  • Last visited

  • Days Won

    2

Posts posted by Frank Vèssia

  1. Hello, I have a template with 32 fields, one repeater and images and I added a function to clone a page via API. It worked since today when suddenly is throwing an sql error, never seen before:
     

    Error: Exception: SQLSTATE[HY000]: General error: 1116 Too many tables; MariaDB can only use 61 tables in a join 

    and from now on, the clone function doens't work anymore. Any idea?

    Thsi si my clone function

    function clonePlate($plate){
    	$pages = wire('pages');
    	$copy = $pages->clone($plate);
    	$copy->setAndSave('title', $copy->title.' (copy)');
    	
    }

     

  2. Hello, I'm having some trouble using the module inside another module.

    It looks like it can't process the "to" email, I'm always getting "Error in hnsmtp::send : it were not specified any valid recipients".

    I simply call the module as I call it inside a template

    $m =  wireMail();
    $m->to($email);
    $m->subject('my subject');
    $m->bodyHTML($body);
    $numSent = $m->send();

    I tried to change the call to $this->modules->get('WireMailSmtp') with no success...what I'm doing wrong?

     

    Edit: I solved it. Maybe it could be helpful for someone else...the send email address in the general setting of the module was wrong (different domain from the one set in the smpt) and somehow it didn't show any error when Wiremail sends an email from a template..

  3. 19 hours ago, Sebi said:

    Hi @Frank Vèssia,

    I finally found time to recreate this once in my test environment. Unfortunately, I cannot reproduce the error.

    My routes definition looks like yours:

    $routes = [
    	'v' => [
    		'1' => [
    			'category' => [
    				['OPTIONS', '{slug:\S+}', ['GET']],
    				['GET', '{slug:\S+}', AppApiTEST::class, 'getCategory'],
    			]
    		]
    	]
    ];

    When I simply dump $data->slug, I get the full "variety" slug when calling the /v/1/category/variety url:

    class AppApiTest {
    	public static function getCategory($data) {
    		$data = AppApiHelper::checkAndSanitizeRequiredParameters($data, ['slug|pageName']);
    		var_dump($data->slug);
    		die();
    	}
    }

    Can you try out if maybe my latest v1.2.6 update, where I improved the route-merging logic, fixed the issue for you? Or could it be something else which is special to your environment (PHP version? Modules or hooks, that could interfer with the AppApi handlers? Maybe it helps to deactivate the new ProcessWire URL Hook in AppApi's settings?)

    mmm....I tried to update the module with no luck, at this point I don't know what it is...I also tried to deactivate some modules...anyway I will do some more test and let you know, thanks for now.

  4. I've been using WireMailSmtp since ages and for some clients we have microsoft exchange 365 emails. Recently Microsoft annouced they are deprecating basic stmp authentication in favor of OAuth 2.0...is there a way to configure WireMailSmtp with this method?

    • Like 1
  5. Hi, I maybe just found a very strange bug.

    I'm using Processwire with a React front end and I setup it in a subdomain like so https://api.mydomain.com/  so just to avoid using api twice i changed the API endpoint into "v" using versions so my base api endpoint is https://api.mydomain.com/v/1/

    Now, everything works fine except when I call a route with a GET parameter starting with "v", it cuts out the v from the slug, for example if I call

    https://api.mydomain.com/v/1/category/variety the get parameter I get it's "ariety" and this happens on all characters I put in the api endpoint, not just for one character

    This is the route I'm using

    'category' => [
    	['OPTIONS', '{slug:\S+}', ['GET']],
    	['GET', '{slug:\S+}', Blog::class, 'getCategory',['application' => 1]], 
    ],

    and this is the function which receives the parameter

     public static function getCategory($data) {
            $data = AppApiHelper::checkAndSanitizeRequiredParameters($data, ['slug|pageName']);
    ...
    
    // $data->slug returns "ariety"

     

    • Like 1
  6. 49 minutes ago, LMD said:

    To use a namespaced (or non-namespaced) class inside another namespaced file, you need to add a slash ('\') before the included classes' namespace. Otherwise, it is looking for the class relative to the file's namespace.

    While it works -- and in this instance doesn't appear to cause issues -- removing a file's namespace negates the reason for using namespaces in the first place.

    Here is an ammended version of your code:

    <?php namespace ProcessWire;
    
    class ProcessSocial extends WireData implements Module, ConfigurableModule {
    
      public function init() {
        $file = __DIR__ . '/vendor/autoload.php';
        if (file_exists($file)) {
              require_once $file;
        }
      }
    
      protected function testFeed($user){
        // Note the '\' before 'GetStream'
        $client = new \GetStream\Stream\Client($api, $key);
        $feed = $client->feed('User', $user);
    
        return $feed->getActivities();
      }
    }

     

    If you find you are calling a class a lot, then you can use a 'use' statement at the top of the file, like this example:

    <?php namespace ProcessWire;
    
    use \GetStream\Stream\Client; // Namespace path to the classname (inc. the classname too)
    
    class ProcessSocial extends WireData implements Module, ConfigurableModule {
    
      public function init() {
        $file = __DIR__ . '/vendor/autoload.php';
        if (file_exists($file)) {
            require_once $file;
        }
      }
    
      protected function testFeed($user){
        // Now you don't need to add the namespace at all here
        $client = new Client($api, $key);
        $feed = $client->feed('User', $user);
    
        return $feed->getActivities();
      }
    }

    Hope that helps.

    Much appreciated, thanks

  7. Hello,
    I'm trying to get to work a getstream.io library inside a module.
    Since I'd like to avoid using composer I downloaded the library from php-download.com which makes it possible just to include the autoloader.php file and using the library directly.
    I tested it inside a template and it works well but I can't inside a module.
    This is what I wrote so far

    inside template:

    <?php
    require_once('./vendor/autoload.php');
    $client = new GetStream\Stream\Client($key, $secret);

     

    Inside module I get error: class GetStream\Stream\Client not found

    <?php namespace ProcessWire;
    
    class ProcessSocial extends WireData implements Module, ConfigurableModule {
    
    ...
    
        public function init() {
            
            $file = __DIR__ . '/vendor/autoload.php';
            if (file_exists($file)) {
                require_once $file;
            }
    
        }
    
    
        protected function testFeed($user){
                
            $client = new GetStream\Stream\Client($api, $key);
            $feed = $client->feed('User', $user);
    
            return $feed->getActivities();
            
        }
    
    }

     

  8. Hello, I'm having a strange issue with the page autocomplete asmselect of a page reference field. Out of a sudden is returning a 403 forbidden error when I type something.
    From the console I find out the system doesn't like the %= operator, it's the only operator which isn't working, I tried others and the select works.
    Any idea why?

    Thanks

  9. I'm trying to change template on the fly (when there is a urlSegment in homepage) and I'm almost there (I guess), the behaviour is strange, the markup is working but if I print the template name I get the home page, something is not working properly
    The code is inside a custom module. Thanks for the help. I'm using v1 (can't use v2)
     

    public function ready() {   
    	$this->addHookBefore('Page::render', $this, 'hookProfiles');
    }
    protected function hookProfiles($event){
            $page = $event->object;
           
            if($page->template == 'home' && wire('input')->urlSegment1 != ''){
                $page->template->set("filename","/site/templates/author.php");
                $factory = $this->modules->get('TemplateEngineFactory');
                $theme   = $factory->load('author.tpl');
                wire()->set('view', $theme);
            }
            
    }
    
  10. 15 hours ago, gebeer said:

    @Sevarf2 where do your images live, in site/assets/imgs? Then you need to define just 'imgs/'

    I just pushed a fix for the error you mentioned to github. You only need to download and replace https://github.com/gebeer/FieldtypeImageReference/blob/master/InputfieldImageReference.module

    Let me know how it goes.

    I'm sorry but there is a new error showing up in logs:  Fatal Error: Uncaught Error: Call to undefined function bd() in /site/modules/FieldtypeImageReference/InputfieldImageReference.module:226 Stack trace:
    1. /site/modules/FieldtypeImageReference/InputfieldImageReference.module(192): InputfieldImageReference->renderThumbnails()

  11. I just installed tracy and I got this error
    image.png.b729d656968f234013386aa669001a5e.png

    I'm using php settings not json

    [
            'name' => 'logotest',
            'label' => __('Logo & Favicon'),
            'type' => 'InputfieldImageReference',
            'width' => '100',
            'fromfolder ' => true,
            'folderpath' => 'assets/imgs/',
            'description' => __('image upload'),
            'collapsed' => 0,
        ],
    

  12. Hi @gebeer I'm trying to use your module within the settingfactory module but I' having some issue initializing it, what are the mandatory parameters to make it work? I tried this config but it shows just the placeholder image. Thanks
     

    [
            'name' => 'logotest',
            'label' => __('Logo & Favicon'),
            'type' => 'InputfieldImageReference',
            'width' => '100',
            'fromfolder ' => true,
            'folderpath' => '/site/templates/',
            'description' => __('description'),
            'collapsed' => 0,
        ],
×
×
  • Create New...