Jump to content

KarlvonKarton

Members
  • Posts

    118
  • Joined

  • Last visited

Everything posted by KarlvonKarton

  1. A question about urlsegments and site structure: In my professional life I mostly replicate private real estate databases to public web databases and develop websites on top of the latter. Now I want to incorporate the real estate data (and my set of classes) into Processwire (as a test). The real estate tables will reside next to the Processwire tables (for now). I plan to make a template immo.php and use it as a controller for all the real estate output. Would it be safe to say that using urlsegments - assuming I allow url segments in the immo template - is the way to go to obtain something like: url.com/immo/sales/p1/welcome-to-the-sales-page or url.com/immo/estate-detail/123/some-friendly-url-of-the-estate-title
  2. Exactly. There is no question anymore. It works. Just wanted to share.
  3. I have tried the second choice of BitPoet too: Somewhere on a page I have two pieces of HTML: <!-- trigger --> <a title=“some title” class="instapast" data-insta=“some_page_id”>linkname</a> <!-- Zurb Foundation Reveal Popup --> <div class="reveal" id="instapastPopup" data-reveal> <h1 id="instapastPopupTitle"></h1> <p id="instapastPopupContent"></p> <button class="close-button" data-close aria-label="Close modal" type="button"> <span aria-hidden="true">&times;</span> </button> </div> The Javascript /templates/scripts/app.js jQuery(document).ready(function($){ var request; $('a.instapast').click(function(){ var id = this.dataset.insta; request = $.ajax({ url: "instapast-ajax/?id=" + id, // instapast-ajax.php is in the directory templates type: "post" }); request.done(function (data, textStatus, jqXHR){ var json = $.parseJSON(data); $('#instapastPopupTitle').html(json.title); $('#instapastPopupContent').html(json.text); $('#instapastPopup').foundation('open'); }); }); }); In Processwire I have made a Template: instapast-ajax And a page with the same name and the template avove: instapast-ajax That gives me the URL for app.js: /instapast-ajax/ The code in instapast-ajax.php: <?php namespace ProcessWire; //$ID = $_GET['id']; // not secure $ID = $sanitizer->int($input->get->id); // updated thanks to bernhard $instagramPickTitle_ = $pages->get($ID)->title; $instagramPickContent_ = $pages->get($ID)->text; $arr = array( 'title' => $instagramPickTitle_, 'text' => $instagramPickContent_ ); $json = json_encode($arr); echo $json; ps: I hope I did not forget something.
  4. Indeed, moving the directory /lib to /site made the PHP file accessible (and was the easiest thing to do for me now): request = $.ajax({ url: "site/lib/instapast-ajax.php", type: "post" }); Thank you, BitPoet and of course bernhard.
  5. @bernhard Is this the answer to the url part? (I only want to know what link should be in the url of the JS.)
  6. Hello, Can anybody tell me how to access a PHP file in: templates/lib/instapast-ajax.php From a javascript file in: templates/scripts/app.js code in app.js: request = $.ajax({ url: "../lib/instapast-ajax.php", // wrong code ? type: "post" }); Thank you.
  7. SOLVED: I've put the getLoginUrl after the getAccessToken section and now the log in works. <?php namespace ProcessWire; // This file is the _init.php $homepage = $pages->get('/'); // FACEBOOK require_once $config->paths->root.'facebook-sdk-v5/autoload.php'; $fb = new \Facebook\Facebook([ // Thank you LostKobrakai 4 the \ 'app_id' => 'my_app_id', 'app_secret' => 'my_app_secret', 'default_graph_version' => 'v2.5' ]); $helper = $fb->getRedirectLoginHelper(); try { $fbAccessToken = $helper->getAccessToken(); } catch(\Facebook\Exceptions\FacebookResponseException $e) { // Thank you LostKobrakai 4 the \ // When Graph returns an error echo 'Graph returned an error: ' . $e->getMessage(); exit; } catch(\Facebook\Exceptions\FacebookSDKException $e) { // Thank you LostKobrakai 4 the \ // When validation fails or other local issues echo 'Facebook SDK returned an error: ' . $e->getMessage(); exit; } $loginUrl = $helper->getLoginUrl($homepage->httpUrl); // Include shared functions include_once("./_func.php"); Source: http://stackoverflow.com/questions/31347341/the-state-param-from-the-url-and-session-do-not-match
  8. The callback is sending a ?code=*** which gives the error (in the post above). $helper = $fb->getRedirectLoginHelper(); $permissions = ['email', 'user_likes']; // optional $loginUrl = $helper->getLoginUrl('http://{your-website}/login-callback.php', $permissions); echo '<a href="' . $loginUrl . '">Log in with Facebook!</a>'; Any suggestions?
  9. But, not there yet... Fatal error: Exception: Cross-site request forgery validation failed. The "state" param from the URL and session do not match. (in /Users/iovalduc/Projectweb Media/Projecten/tits-and-party/Web/www/facebook-sdk-v5/Helpers/FacebookRedirectLoginHelper.php line 285) #0 /Users/iovalduc/Projectweb Media/Projecten/tits-and-party/Web/www/facebook-sdk-v5/Helpers/FacebookRedirectLoginHelper.php(249): Facebook\Helpers\FacebookRedirectLoginHelper->validateCsrf() #1 /Users/iovalduc/Projectweb Media/Projecten/tits-and-party/Web/www/site/templates/home.php(43): Facebook\Helpers\FacebookRedirectLoginHelper->getAccessToken() #2 /Users/iovalduc/Projectweb Media/Projecten/tits-and-party/Web/www/wire/core/TemplateFile.php(219): require('/Users/iovalduc...') #3 [internal function]: ProcessWire\TemplateFile->___render() #4 /Users/iovalduc/Projectweb Media/Projecten/tits-and-party/Web/www/wire/core/Wire.php(347): call_user_func_array(Array, Array) #5 /Users/iovalduc/Projectweb Media/Projecten/tits-and-party/Web/www/wire/core/WireHooks.php(548) in /Users/iovalduc/Projectweb Media/Projecten/tits-and-party/Web/www/index.php on line 64
  10. The backslash did the trick. Thank you, LostKobrakai.
  11. Hello, I'm trying to implement the Facebook SDK in my Processwire website, but that is not going quite well... I have an _init.php wherein I've put: // FACEBOOK require_once $config->paths->root.'facebook-sdk-v5/autoload.php'; $fb = new Facebook\Facebook([ 'app_id' => 'the_id', 'app_secret' => 'the_secret', 'default_graph_version' => 'v2.5' ]); But that gives me the error (not finding the class): Fatal error: Class 'ProcessWire\Facebook\Facebook' not found in /Users/iovalduc/Projectweb Media/Projecten/tits-and-party/Web/www/site/templates/_init.php on line 38 What am I doing wrong? Is the root of the website a good place to put the SDK folder? Should I check all the paths in the Facebook SDK scripts? Will "__DIR__" in the SDK scripts ever work within Processwire?
  12. Thank you for the directions. Exactly what I needed. I just re-installed the multi language option. Renamed the default language English (en) to Dutch (nl). Installed a dutch language pack over the old English one. Deleted the German and Finnish pre-installation and I installed French as the second language. Before I forget: I changed the page names on the homepage too (in the settings tab). Except for some minor translations issues that can be fixed, there is no sign of English anymore.
  13. One more thing. I tested out the solutions of ESRCH, with success. In the LanguageDefault Class the '/' is redirected to /nl/ (in my case) But since I only need Dutch (nl) and French (fr), but no English, I've hidden English in the setup -> languages -> English (tab settings -> status: hidden). The great thing(s) about that: in the language selector there is only French and Dutch (on the site) and all options of English are disabled in the admin. (I can not think of any other reason why the default language can be hidden?) However, and I don't know if this is some kind of bug, everytime I save a page (or even some other things), then I get an error "missing required value". I found out that the missing value is actually the English translation. So all the English options are hidden, but the script still needs the values after posting the form (e.g. saving a page). When I make English visible again (thus uncheck hidden) then the error disappears. I find this behavior highly peculiar. Any comments?
  14. How about the effect on search engines with the solution of ESRCH? I think search engines are not very happy with redirects like that (where the URL changes).
×
×
  • Create New...