Jump to content

neildaemond

Members
  • Posts

    134
  • Joined

  • Last visited

Posts posted by neildaemond

  1. It works great. I hoped to be able to add one image, but suddenly I can add even more.

    I'm not sure of the format in which to enter the 'image' column... I saw apeisa put a full url to his image column. Would this module then download the image from the link and put it in into the assets folder? or would the system always load that image from the mentioned url (ie, setting the url field equal to any, possibly external, link.)

    If it does set to url field to the specified URL, then it may be a good opportunity to use a cdn for images, although I doubt it will work well that way if using the width() or height() resizers..

    otherwise, I'm assuming the image is downloaded and saved to the assets folder.

    Am I way off?

  2. if you are checking for roles in your templates, you can maybe get away with checking something like if:

    $user->hasRole($sanitizer->name($page->title))   //for the section page
    
    or
    
    $user->hasRole($sanitizer->name($page->parent->title))   //for the news, etc... if they are sub pages
    

    then make your roles called ParishCouncil and CricketClub

    • Like 1
  3. I use the XMLsitemap generator module to create a sitemap.xml

    then in the robots.txt is just put:

    sitemap: http://www.domain.com/sitemap.xml

    seems to get indexed quite easily by google...

    Edit: wait, I submit the xml sitemap specifically to google, but the sitemap in the robots seems to help all those random bots crawling my page (probably not the best thing since those ones are prob just copying content to a third party site...)

    • Like 1
  4. The module is FieldtypePage. I'm not sure how to configure the field options...

    I'm trying to do my field creations with the api but I never know how to configure the field options either. Is there any documentation for this?

    $f = new Field();
    $f->type = $this->modules->get("FieldtypePage");
    $f->name = 'mypageselect';
    $f->label = 'Select Page';
    $f->derefAsPage = FieldtypePage::derefAsPageOrNullPage;
    $f->inputfield = 'InputfieldPageListSelect';
    $f->save();
     

    or

    $f->derefAsPage = FieldtypePage::derefAsPageArray;
    $f->inputfield = 'InputfieldAsmSelect';

    etc

    thanks, wow I would have never of guessed.

  5. Any calls to a function that returns a PageArray (like $page->children(), $pages->find(), etc.) are going to exclude pages that are hidden, unpublished or otherwise inaccessible to the user. To make it include them, you can specify one of these:

    • include=hidden -- includes hidden pages. 
    • check_access=0 -- Includes pages the user doesn't have view access, as a result of role permissions.
    • include=all -- includes all pages with no restrictions.

    thanks for that, I had this question in the back of my head too~

  6. 
    

    Quick question for anyone who is familiar with it..

    If creating a new text field with the api looks something like this:

    $nf = new Field();  

    $nf->type = $this->modules->get(FieldTypeText);

    $nf->save();

    Then how would I create that field which allows me to select multiple pages (which module do I get and set type as)

    I usually just choose from modules under wire/modules/Fieldtype. But, in this case I'm not sure which one it is.

    I know I could dereference any pagearray as a string and save the pipe delemited string to the text field, but I'd liek to have the pageselect functionality in the admin.

    Thanks In Advance

  7. foreach($templates as $template){
       $postsparent = $pages->get('/path/to/parent/');
       $cwt = $postparent->children("template=$template->name");
       if(count($cwt)){
         echo "$template->name: \n";
         foreach($cwt as $tp){
           echo "\t $tp->name \n";
         }
       }
    }
    

    i think this would list out the child pages of any parent grouped by which template they have. Not tested though, and not too sure if children("template=$template->name") is valid :)

    • Like 1
  8. Hi guys,

    for some strange reason,  under the google analytics, I'm seeing pages like:

    /address/of/page/www.domain.com

    /address/of/other/page/www.domain.com

    and they seem to be getting hits.

    I've recently added page link abstractor to the 'body' textarea field, and I know it only works for text after it is saved (therefore, shouldn't affect original fields).

    anyone ever seen bahavior like this?

    weirdGApages.png

  9. only the homepage of the subdomain works for me.

    if I try go to:

    subdomain.site.com/yadayada/

    nothing happens. see:

    corporate.ccw-global.com

    www.ccw-global.com

    Edit: I ended up moving the subdomain back to having it's own database. It might be more hassel to admin, but simpler to ensure good SEO with two different XML sitemaps. I had a few instances where /domain/subdomain/ due to the way pages were linked.

    Anyways, I'll look forward to when this module gets beefed up, or when a next gen version gets released.

  10. u.have pw tamplate caches turded on?

    Hmm, I don't remember ever turning it on. I'm not 100% how to check, but under modules the 'Cache' module (under Pagefield) isn't installed, and the 'Markup Cache' and 'Page Render' modules are permanently installed and I just tried clearing them now... didn't work

    as for the code, to start with I used pretty much the exact same code from here http://coding.smashingmagazine.com/2011/09/05/getting-started-with-the-paypal-api/

    this part went in my 'payment' page

    class Paypal {
      /**
       * Last error message(s)
       * @var array
       */
      protected $_errors = array();
    
      /**
       * API Credentials
       * Use the correct credentials for the environment in use (Live / Sandbox)
       * @var array
       */
      protected $_credentials = array(
      'USER' => 'seller_1297608781_biz_api1.lionite.com',
      'PWD' => '1297608792',
      'SIGNATURE' => 'A3g66.FS3NAf4mkHn3BDQdpo6JD.ACcPc4wMrInvUEqO3Uapovity47p',
      );
    
      /**
       * API endpoint
       * Live - https://api-3t.paypal.com/nvp
       * Sandbox - https://api-3t.sandbox.paypal.com/nvp
       * @var string
       */
      protected $_endPoint = 'https://api-3t.sandbox.paypal.com/nvp';
    
      /**
       * API Version
       * @var string
       */
      protected $_version = '74.0';
    
      /**
       * Make API request
       *
       * @param string $method string API method to request
       * @param array $params Additional request parameters
       * @return array / boolean Response array / boolean false on failure
       */
      public function request($method,$params = array()) {
      $this -> _errors = array();
      if( empty($method) ) { //Check if API method is not empty
    	 $this -> _errors = array('API method is missing');
    	 return false;
      }
    
      //Our request parameters
      $requestParams = array(
    	 'METHOD' => $method,
    	 'VERSION' => $this -> _version
      ) + $this -> _credentials;
    
      //Building our NVP string
      $request = http_build_query($requestParams + $params);
    
      //cURL settings
      $curlOptions = array (
    	 CURLOPT_URL => $this -> _endPoint,
    	 CURLOPT_VERBOSE => 1,
    	 CURLOPT_SSL_VERIFYPEER => true,
    	 CURLOPT_SSL_VERIFYHOST => 2,
    	 CURLOPT_CAINFO => dirname(__FILE__) . '/cacert.pem', //CA cert file
    	 CURLOPT_RETURNTRANSFER => 1,
    	 CURLOPT_POST => 1,
    	 CURLOPT_POSTFIELDS => $request
      );
    
      $ch = curl_init();
      curl_setopt_array($ch,$curlOptions);
    
      //Sending our request - $response will hold the API response
      $response = curl_exec($ch);
    
      //Checking for cURL errors
      if (curl_errno($ch)) {
    	 $this -> _errors = curl_error($ch);
    	 curl_close($ch);
    	 return false;
    	 //Handle errors
      } else  {
    	 curl_close($ch);
    	 $responseArray = array();
    	 parse_str($response,$responseArray); // Break the NVP string to an array
    	 return $responseArray;
      }
      }
    }
    //Our request parameters
    $requestParams = array(
      'RETURNURL' => 'http://www.yourdomain.com/payment/success',
      'CANCELURL' => 'http://www.yourdomain.com/payment/cancelled'
    );
    
    $orderParams = array(
      'PAYMENTREQUEST_0_AMT' => '500',
      'PAYMENTREQUEST_0_SHIPPINGAMT' => '4',
      'PAYMENTREQUEST_0_CURRENCYCODE' => 'GBP',
      'PAYMENTREQUEST_0_ITEMAMT' => '496'
    );
    
    $item = array(
      'L_PAYMENTREQUEST_0_NAME0' => 'iPhone',
      'L_PAYMENTREQUEST_0_DESC0' => 'White iPhone, 16GB',
      'L_PAYMENTREQUEST_0_AMT0' => '496',
      'L_PAYMENTREQUEST_0_QTY0' => '1'
    );
    
    $paypal = new Paypal();
    $response = $paypal -> request('SetExpressCheckout',$requestParams + $orderParams + $item);
    
    if(is_array($response) && $response['ACK'] == 'Success') { //Request successful
      $token = $response['TOKEN'];
      header( 'Location: https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token=' . urlencode($token) );
    }
    

    and this part goes in my 'success' page which paypal redirects me to after the paypal user logs in and confirms the purchase on their end

    
    class Paypal {
    ...
    }
    if( isset($_GET['token']) && !empty($_GET['token']) ) { // Token parameter exists
      // Get checkout details, including buyer information.
      // We can save it for future reference or cross-check with the data we have
      $paypal = new Paypal();
      $checkoutDetails = $paypal -> request('GetExpressCheckoutDetails', array('TOKEN' => $_GET['token']));
    
      // Complete the checkout transaction
      $requestParams = array(
          'TOKEN' => $_GET['token'],
          'PAYMENTACTION' => 'Sale',
          'PAYERID' => $_GET['PayerID'],
          'PAYMENTREQUEST_0_AMT' => '500', // Same amount as in the original request
          'PAYMENTREQUEST_0_CURRENCYCODE' => 'GBP' // Same currency as the original request
      );
    
      $response = $paypal -> request('DoExpressCheckoutPayment',$requestParams);
      if( is_array($response) && $response['ACK'] == 'Success') { // Payment successful
           echo "success"
          // We'll fetch the transaction ID for internal bookkeeping
          $transactionId = $response['PAYMENTINFO_0_TRANSACTIONID'];
      }
    }
    

    Note: The following code (from above) needs to have your specific details

    protected $_credentials = array(
      'USER' => 'seller_1297608781_biz_api1.lionite.com',
      'PWD' => '1297608792',
      'SIGNATURE' => 'A3g66.FS3NAf4mkHn3BDQdpo6JD.ACcPc4wMrInvUEqO3Uapovity47p',
      );
    
    $requestParams = array(
      'RETURNURL' => 'http://www.yourdomain.com/payment/success',
      'CANCELURL' => 'http://www.yourdomain.com/payment/cancelled'
    );
    

    also, you need a cacert.pem. I got from cURL website and put it in same folder as Paypal class

    again, It works if my success page is in another success.php file outside of my PW site.

    Also, I'm using PW 2.2.9 and installed it using the blank profile (i think soma made).

    Thanks guys, this issue I'm having is really frustrating me, is quite crucial, and needed it working days ago.. haha.

  11. I'm trying to get Paypal express checkout working... After going through the process, paypal redirects me back to my site where I'm supposed to grab the get variable 'token'

    anyways, I could never see it, and finally tried getting paypal to redirect to a page outside the PW site with the same code. The variables were now there.

    Come to think of it, I haven't been able to post forms to other pages either. The forms work when they post to themselves, but not when they post to other pages.

    Is this a security measure so that people cannot post false values to the page?

    Perhaps there's a setting somewhere I can change?

    EDIT (Solved):

    I went to

    setup => templates => template name => urls

    and I set "should page urls end with a slash?" to NO.

    EDIT (Even Better Solution):

    Make sure my return urls have slashes on them, also my urls in forms. Thanks Soma!

  12. I'm creating a service which sells something like a subscription to a product.

    First, someone inputs their preferences, then if they are not logged in the preferences are saved to session variables while the user is prompted to sign up or login. Upon sign up, the session preferences will be used to create an order for the subscription.

    This order is actually just a page created as a child of the user, using the 'order' template.

    I've managed to create the child page of the user by making its parent equal to $user. However, I want to list out all the user's orders but I don't think I'm doing it properly.

    making the 'order':

        $b = new Page();
        $b->template = 'order';
        $b->parent = $user;
        $b->name = 'order' . $b->created ;
        $b->title = 'Order For '.$session->order_name ;
        $session->order_name = '';
    
        $b->save();
    

    trying (but failing) to list out the orders:

    foreach($user->children() as $order){
        echo $order->name;
    }
    

    How can I make it so a user can view their child pages? or is it just a bad idea to make these orders as children of the $user? Should I instead just create orders under a page(directory) named /orders/ ? how would I protect those?

    the $user is not a superuser, nor does it have any associated roles yet. perhaps I need to give them a role and allow that role access the page? however, that may give all users with that role access to pages which aren't theirs. Maybe i need to use that module which allow user access to one page(i havn't tried yet). I will try these guesses first...

    Thanks in advance for any advice,

  13. I noticed that jquery ui classes like ui-widget-header and ui-widget are in the rendered form. After adding jquery ui css to my site, all the form styles got wonky.

    They are probably important for the admin section forms but, is there a way to make it so that those classes are not populated when rendered on my pages?

  14. I found Janko's FormToWizard code to be one of the simplest ways to implement a multi-page/multi-slide form. Now with the Processwire this just got easier. I tweaked his script a wee bit to work with the API forms described in this thread.

    PWformToWizard.js

    bunching your fields into fieldsets just as Ryan described above, each fieldset will become a page/slide. Instead using the <legend> tag that Janko uses, the script now generates a legend based on the label, specifically anything that comes before a colon ':'

    first add the script:

    <script type="text/javascript" src="PWformToWizard.js"></script>
    
     

    then use this javascript to initiallize formToWizard:

    $("#SignupForm").formToWizard();
    
     

    the default styles are:

       <style type="text/css">
        body { font-family:Lucida Sans, Arial, Helvetica, Sans-Serif; font-size:13px; margin:20px;}
        #main { width:960px; margin: 0px auto; border:solid 1px #b2b3b5; -moz-border-radius:10px; padding:20px; background-color:#f6f6f6;}
        #header { text-align:center; border-bottom:solid 1px #b2b3b5; margin: 0 0 20px 0; }
        fieldset { border:none; width:320px;}
        legend { font-size:18px; margin:0px; padding:10px 0px; color:#b0232a; font-weight:bold;}
        label { display:block; margin:15px 0 5px;}
        input[type=text], input[type=password] { width:300px; padding:5px; border:solid 1px #000;}
        .prev, .next { background-color:#b0232a; padding:5px 10px; color:#fff; text-decoration:none;}
        .prev:hover, .next:hover { background-color:#000; text-decoration:none;}
        .prev { float:left;}
        .next { float:right;}
        #steps { list-style:none; width:100%; overflow:hidden; margin:0px; padding:0px;}
        #steps li {font-size:24px; float:left; padding:10px; color:#b0b1b3;}
        #steps li span {font-size:11px; display:block;}
        #steps li.current { color:#000;}
        #makeWizard { background-color:#b0232a; color:#fff; padding:5px 10px; text-decoration:none; font-size:18px;}
        #makeWizard:hover { background-color:#000;}
       </style>
       <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
       <script type="text/javascript" src="formToWizard.js"></script>
       <script type="text/javascript">
        $(document).ready(function(){
    	    $("#SignupForm").formToWizard({ submitButton: 'SaveAccount' })
        });
       </script>
    
     

    see janko's page for more info~

    Now, just to add some responsive jquery validation to each 'next' button...

    • Like 7
    • Thanks 1
×
×
  • Create New...