Jump to content

Manol

Members
  • Posts

    292
  • Joined

  • Last visited

Posts posted by Manol

  1. Trying to resize an image that way but gives me a 500 error

     

    //OPTION A (500 error)
    echo "<img src='{$page->images->eq(0)->resize(340,480)->url}' alt=''>"
    
    
    //OPTION B  (500 erro either)
    $myImage = $page->images->eq(0);
    $myResized = $myImage->resize(340,480);
    echo "<img src='{$myResized->url}' alt=''>"

     

  2. Hi nmendes, awesome module, don't know if you're still maintaining it. I think a couple improvements could be done:

    1. Would be the possibility to mimic the pw structure under a folder within a bucket that way many different webpages could use the same bucket ( because the number of buckets per user is limited)
    2. That one would be the best if you could. Not mimic pw structure but use S3 as the place to save the files, because Gb price on a server is far more expensive than using S3 (used by dropbox, spotify and other big companies), if you've a page with many videos, audios...

    Thanks and congratulations.

  3. I'm using PW 2.6.1

    $markas_cached = $cache->get("marcas", "+1 second", function($pages) {
                $markas = ["DAF", "IVECO", "LIEBHERR", "MAN", "MERCEDES", "RENAULT", "SCANIA", "SCHMITZ", "VOLVO"];
                return $markas;
    }); 
    echo json_encode($cache->get("marcas"));
    echo json_encode($markas_cached);
    

    I've changed array values manually $markas = ["DAF", "IVECO"] with different times with the template way but the array values never change. Any ideas.

  4. Is there a way to persist variables across different users without being logged and without writing the variable result to a file.

    In my case the admin publishes several vehicles of different branches, these my differ every day so I've used LazyCron to check active branches every two hours, to avoid querying DB each time a user look for vehicles, I tried putting the result in a session variable but it doesn't work between different users.

     I could write the branches every two hours to a file and read it every time but, is there a better way to do it?

    Thank you.

  5. Hi Sephiroth.

        

        I can get data back if the template that the page uses has a guest role.

        I don't have any problem with cordova when I use it with dreamfactory I can login retrieve data upload images... but because I like pw I would like to do the same with it but as mentioned before I'm not able to retrieve data from a page that uses a template with a role different to guest.

        The problem is my knowledge I suppose making calls through ajax to log to pw and get the data back. 

  6. I would like to create a page that uses a template that returns some data, as "pages web service" but this template can be accessed only by certain role.

    Then a user must send credentials through ajax to get the data back , the http call comes from a phone, so the page trying to access the data is not on the server, is there a way to do it?

    I've search all around the forum but no way to get it working. Anybody has done something similar? How did you solve it?

    Thank you.

  7. Hi BitPoet

    I've but get the following error

    XMLHttpRequest cannot load http://miweb/login/. Response to preflight request doesn't pass access control check: A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header when the credentials flag is true. Origin 'http://localhost:9000' is therefore not allowed access.


    In my php file

    header('Access-Control-Allow-Origin: *');
    header("Access-Control-Allow-Methods: PUT, GET, POST, DELETE, OPTIONS");
    header("Access-Control-Allow-Headers: Authorization, X-Requested-With, Content-Type, Origin, Accept");
    header('Access-Control-Allow-Credentials: true');
    

    an in my angularjs file

        .config( function($routeProvider, $httpProvider){
            $httpProvider.defaults.useXDomain = true;
            $httpProvider.defaults.withCredentials = true;
            delete $httpProvider.defaults.headers.common['X-Requested-With'];        
        })
    
  8. Hi.

       Is there a way to login to processwire from ajax keep the session and then call a page which uses a template allowed to certain role to get some data back? The problem is that is a mobile app and is not in the same server so its like cookies where lost.

       I'm developing a mobile application with cordova to get information about some monuments (images, description, visit timetable...),  the data of those pages is only available by certain role, so users must login, so far so good but  when I try to call to get monuments data I get no permission.

      Is there a way to login to pw through ajax and than call again to get more data from the server?

  9. I've in my php file

    <?php 
    header('Access-Control-Allow-Origin: *');
    /* Allowed request method */
    header("Access-Control-Allow-Methods: PUT");
    /* Allowed custom header */
    header("Access-Control-Allow-Headers: Content-Type");
    

    when I make calls with ajax(angular), it works

    		this.login = function (creds) {
    			var deferred = $q.defer();
    	  		$http({
    	  			method: 'POST',
    	  			url: 'http://miwebpage.com/api/login/',
    	  			data: {'user': creds.username, 'pass': creds.password}
    	  		})
    	  		.success(function (result) {
    				deferred.resolve(result);
    	  		})
    	  		.error(function(data){
    	  			deferred.reject;
    			});	
    			return deferred.promise;
    		}
    

     I would like to use a token in every call (csrf?), how can I achieve that in ajax ( angular ), any tutorials? I've searched but not sure yet how to do it with pw and csrf.

  10. Hi I'm trying to get some json formatted data through ajax from a template that has permission for certain role only.

    If I'm logged as an admin in a tab and just call http://mydomain.com/getitems/ in a different tab a get the json data back. 

    Here is my code.

    PHP

    
    <?php 
    
    header('Access-Control-Allow-Origin: *');
    
    foreach ( $items as $item) { 
      array_push($array, array( "label"  => $item ) ); 
    }
    echo json_encode($array);
    

    JS

    $http({
       method: 'POST',
       url: 'http://mydomain.com/getitems/'
    })
    .success(function (result) {
       console.log("result",result)
    })
    .error(function(data){
       console.log("error",data)
    });	
    

    It does work as long as the template containing the PHP code is guest available, but if I allow it to be visible by a role a get a null response, even if I'm logged in another tab in the same browser as administrator.

    My question is:

    Is there a way to send my credentials through the js call to get the data back?

    Any help would be appreciated. Thank you.

  11. Finally I got it.

    Here is the code and a couple of self explanatory images to show what you have and what you get.

    post-1191-0-65711500-1444820045_thumb.pn

    post-1191-0-67368500-1444820053_thumb.pn

    	protected function getFieldsets( $pageID ){
    
    		$pagina = wire('pages')->get($pageID);
    
    		$campos = array(); $array = array();  $temp = null;
    
    		foreach($pagina->fields as $field) {
    
    			if($field->type->name == "FieldtypeFieldsetOpen") {
    				$temp = $field->name;
    			}
    			elseif($field->type->name == "FieldtypeFieldsetClose") {
    				$campos = array(); $temp = null;
    			}
    			else {
    				if($temp!=null){
    					array_push($campos, $field->name); $array[$temp]= $campos;
    				}	
    			}
    
    	    }
    
    		return json_encode($array);
    
    	}
    
    • Like 1
  12. Hi guys.

        Is there a way to get fields included within a FieldsetOpen?

        I would like to render in the frontend in several columns  FieldsetOpen labels and the fields within it.

    Thank you.

×
×
  • Create New...