Jump to content

louisstephens

Members
  • Posts

    516
  • Joined

  • Last visited

Everything posted by louisstephens

  1. This currently is bug as ProcessPageEdit allows a super user to select any template. Abdus suggested a tweak that has worked for another user, and it can be found here:
  2. Thanks @mke and everyone else for the help. I got the "content-type" in the headers to return as application/json now. It's odd to me that I can call response.headers and return all the header information for the call, but the data is just blank. I looked at the json on the the actual page and it is being returned as: [{"title":"Development","summary":"Epic cheeseburgers come in all kinds of manifestations, but we want them in and around our mouth no matter what. Slide those smashed patties with the gently caramelized meat fat between a toasted brioche bun and pass it over. You fall in love with the cheeseburger itself but the journey ain\u2019t half bad either.","body":" They\u2019re the childhood friend that knows your highest highs and lowest lows. They\u2019ve been with you through thick and thin and they\u2019re the best at keeping secrets. Whether it\u2019s dressed up or informal, cheeseburgers have your back.<\/p>\n\n Sometimes we lose sight of what really matters in life. There\u2019s something to be said for a gourmet brie and truffle burger paired with parmesan frites, but don\u2019t let that make you forget about the ol\u2019 faithful with American cheddar and a squishy bun. Lettuce remind you that cheeseburgers come in all forms - bun intended.<\/p>\n\n Pop quiz: what\u2019s the greatest thing to happen to your mind, body, and soul in recent history? A cheeseburger, obviously. Cheeseburgers know that what you want can also be what you need.<\/p>"}] (dont mind the placeholder text. Cheeseburger Ipsum.) I do have processwire in a subfolder, and my vue app is in a folder outside (just so I did not get to turned around). I also checked to make sure my api call began and ended with a slash as suggested but it doesnt seem to make a difference as of yet. My get response appears to be "200" coming from the vue app as well, so now I am just really baffled. ** Edit ** I did just find if I take my foreach statement: <?php $myPages = $pages->find('template=basic-page'); $data = $myPages->explode(['title', 'summary', 'body']); echo wireEncodeJSON($data); ?> and remove it outside of if ($config->ajax && $input->urlSegment1 == 'test-api') { } then the data attribute is properly filled out.
  3. Thanks zeka, I was playing around with your suggestion, but if I look at the console, "data" is completely empty. I can out put the "json" by just encoding it, but it isnt passing anything actual to the app. Ill keep searching. { "data": "", "status": 200, "statusText": "OK", "headers": { "pragma": "no-cache", "content-type": "text/html; charset=utf-8", "cache-control": "no-store, no-cache, must-revalidate", "expires": "Thu, 19 Nov 1981 08:52:00 GMT" }, "config": { "transformRequest": {}, "transformResponse": {}, "timeout": 0, "xsrfCookieName": "XSRF-TOKEN", "xsrfHeaderName": "X-XSRF-TOKEN", "maxContentLength": -1, "headers": { "Accept": "application/json, text/plain, */*" }, "method": "get", "url": "http://1ocalhost:8888/development/sites/test/ajax-actions/test-api/" }, "request": {} }
  4. Thanks dragan. In my head I just assumed that I would need to bootstrap it. I tried doing a simple ajax request like {{info}} is in the actual markup for the controller: import axios from 'axios'; export default { name: 'Api', data () { return { info: null } }, mounted () { axios .get('http://localhost:8888/development/sites/test/ajax-actions/test-api') .then(response => (this.info = response)) } } And in my processwire ajax-actions.php file: <?php else if ($config->ajax && $input->urlSegment1 == 'test-api') { $searchResults = $page->find("template=basic"); $json = array(); foreach($searchResults as $search){ $json[] = array( 'title' => $seach->title, ); } echo json_encode($json); } ?> I guess I have two issues with this setup. 1. In my console on my vue app, I get No 'Access-Control-Allow-Origin' header is present on the requested resource 2. And secondly, data that is output seems to be just " "{ "data": "", "status": 200, "statusText": "OK", "headers": { "pragma": "no-cache", "content-type": "text/html; charset=utf-8", "cache-control": "no-store, no-cache, must-revalidate", "expires": "Thu, 19 Nov 1981 08:52:00 GMT" }, "config": { "transformRequest": {}, "transformResponse": {}, "timeout": 0, "xsrfCookieName": "XSRF-TOKEN", "xsrfHeaderName": "X-XSRF-TOKEN", "maxContentLength": -1, "headers": { "Accept": "application/json, text/plain, */*" }, "method": "get", "url": "http://localhost:8888/development/sites/test/ajax-actions/test-api" }, "request": {} } What have I missed? Sorry, I am still trying to figure this all out.
  5. So I have been diving into vue.js lately, and I am really impressed. I thought it could be perfect for an internal dashboard using PageQuerry boss to retrieve the data. However, I do have a few questions that someone might be able to guide me with before I fully commit. 1. Is it even possible to bootstrap pw into a vue app? 2. How would it be possible to handle user registration/logins without actually having to mirror the users on pw in another service? 3. I know I could easily use an iframe in a modal to handle page editing (as I have done it inside of pw before), but would this be the best solution?
  6. I have used a lot of project management tools over the years, and I will say, I do like Monday. I built something (utilizing pw) based off the idea just as a test to my abilities. Unfortunately, I had something go wrong with the db so I had to get a fresh copy up and running. I made a page reference field (projects) for the user template and on the front end you could assign the user to the project (ajax call then selected the appropriate page in the user template). From there, the project page showed all tasks added to it with dates. Ill see if I can resurrect the app and take some screenshots.
  7. Sorry @OLSA for the confusion. I was pretty frustrated and my question probably got garbled. Hopefully I can clear up what I am trying to do, as I switched gears a bit now that I have had time to think. The setup: 1. Repeater - dev_repeater - Image field (set to allow one) - dev_image 2. Nested Repeater - dev_button_repeater - Text Field - URL text to display on front-end - URL Field - dev_url - allows user to enter url (ie http://google.com), but if the item needs a data-attribute (for some ajax request), then they can use a hanna code [[data]] to add the attribute to the URL on the front end I guess what I am trying to do, in the hanna code, is get the image url so it can be present in the data attribute. Perhaps a nested repeater is not the way to go, but I didnt know of another way to allow the user to "add" multiple items all with different values.
  8. Ill be honest, I am a bit unsure how accomplish this. I have a repeater (dev_repeater) that contains an image field set to 1 image. Nested within this repeater, is another repeater (dev_child_repeater) that allows a user to add in some urls. However, there is also a hidden field that I am trying to pass the parent repeater's image path. I know I can output all the data by using: <?php foreach($page->dev_repeater as $repeater) { foreach($repeater as $url) { # do some stuff } } ?> For the life of me, I can not figure out how to obtain the image url in my php to pass to a variable inside the nested foreach loop. Hopefully this made some sense.
  9. Just curious, since you are using child pages as uikit elements, how does this effect actual child pages? For example, if you had "Services" built out with the "sections"/child pages, but then you have actual child pages of Services. Does this not get a bit messy?
  10. Thanks elabx. I might need a bit more help here. I currently have [[print_image]]: onclick="printJS({printable: 'path_to_image', type: 'image'});" But I also need "path_to_image" filled out, but I wasnt sure how to echo the php inside of a hanna code that was set to "text/html". Perhaps I am making this more difficult than it needs to be, but I was trying to work around using if statements in my actual template to check whether the user typed a url vs the shortcode.
  11. I have a repeater with a text field where I would like to use hanna code (to make it easier on the user) so the user can define the action of a image that is in the repeater. For example: 1. The image should have an external link: - the user can just type in the url 2. The image, when clicked, should be printable (using print.js) - the user can just type [[print_image]] That works just fine, but I am running into an "issue". The code I need to use to print is: onclick="printJS({printable: 'path_to_image', type: 'image'});" I can put that into the hanna code as plain text, but I have no idea how to get the image from the repeater item and pass to "path_to_image". Is this even possible?
  12. Is it possible for you to change the email associated with one of the accounts to something else?
  13. Thanks @netcarver for the detailed line. Horst's approach worked really well with a very small feed, and I was learning how to make a module to potentially handle this. I was hopping to tap into a cron job to handle the updating/adding at a specific time, like midnight every night, but maybe lazycron might work inside the module. I havent done much research into actually hooking into lazy cron within a module and getting the module to perform the functions similiar to horst's example above. However, you make a good point regarding page size. I believe max I will be dealing with maybe 500 to 600 max (though could be as low as 200). I would say I am getting a lot better with php as my background is in front-end, but I am enjoying the learning process. Since the items will have a status (new, used, or sold), I was thinking that I could potentially write a function to trash the items marked as sold after a 24 hour period and empty the trash. Well, this was my thought earlier in my pre-planning stages.
  14. There are a few discussions in the forums regarding this, but I don't think any of them gave a definite solution. @teppo also created a module about 5 years ago for relocating assets. However, I am not sure regarding the compatibility with the latest processwire versions. https://github.com/teppokoivula/PageRenderRelocateAssets You might also want to look at the AIOM+ module for processwire which has domain sharding (for CSS, LESS, JS, and html).
  15. Perhaps I am missing something here, but where is the "singular" and "isAutoload" at for the module? I am running into the same issue that kongondo mentioned, but can not find anything to change.
  16. Wow Horst! I cant thank you enough for your insight as well as the example. To be honest, I had know idea about crc32 or using uncache. I do have a question though, what are the benefits of using uncache when creating a new page within the functions?
  17. I have a script that is pulling in a json feed (will be attached to a cron job later) which looks like: $http = new WireHttp(); // Get the contents of a URL $response = $http->get("feed_url"); if($response !== false) { $decodedFeed = json_decode($response); } Everything there works well and I can pull the id, title, status (updated, new, sold) and other items from the decoded feed in a foreach loop. My whole goal is to create pages from the feed, but if the page has already been created, with all the same exact items from the json feed, I will need to "skip" over it. So far, I am running into a roadblock with my checks. I guess I need to compare the json to all my pages and their values and: 1. If an id already exists, check to see if a fields data has been updated and then update the page, 2. If an id exists and all fields are unchanged, skip adding that page $http = new WireHttp(); // Get the contents of a URL $response = $http->get("feed_url"); if($response !== false) { $decodedFeed = json_decode($response); foreach($decodedFeed as $feed) { $u = new Page(); $u->template = $templates->get("basic-page"); $u->parent = $pages->get("/development/"); $u->name = $feed->title = $feed->id; $u->title = $feed->title; $u->status = $feed->status $u->body = $feed->title; $u->save(); $u->setOutputFormatting(false); } } else { echo "HTTP request failed: " . $http->getError(); } I am really just hung up on how to do the current page checks and matching them with the json field data.
  18. Glad you figured it out! You can edit your first post, and it will give you the option to edit the title as well. Normally, people just add [SOLVED] to the beginning of the title.
  19. Thanks @elabx.. I did not initially realize that $user already had that information "saved". Works like a charm.
  20. So I am building a dashboard for the front-end of a small app I am making, and I was wanting to display certain pages in the side bar based on the user. So far, I made a page reference field called page_author that allows a user to select from a list of users (I just pointed the page reference field to users under the admin).So far, that is working nicely, however, I have not hit a wall. I am not so sure how to output pages based on the selected user. In my dashboard template, I know I could do $current = $pages->find("template=secondary, page_author="); foreach($current as $list) { // some code here } But I guess I am struggling to figure out how to tie the logged in user to the selected user in page_author. Hopefully to clear things up: User "Bob" has created some pages and selected "Bob" in page_author. Now when he goes to their front-end dashboard, he will only see pages that have "bob selected. But if Amy goes to the dashboard, they will not see any items accredited to Bob, but she will see her own items.
  21. I will say, I downloaded the module using the class from the module directory, and font awesome 4 was the only option to select in the options (though the FontAwesome5.php was there). I uninstalled the module and installed from the github page and you can select Font Awesome 5.
  22. I completely agree with everything everyone has said thus far regarding WP. If I "have" to do anything with wordpress, I use typerocket. The framework makes it a lot more enjoyable to work with (IMHO) and has repeaters as well.
  23. I can confirm, I am using processwire 3.0.98 with the Upgrade module 0.0.7 and I have the following:
  24. I believe you have to have a login with a role with proper permissions other than guest to be able to edit content. As far as I understand, the guest role does not have page edit permissions (unless you have changed this).
  25. Thanks elabx, I cant believe I missed that. I found people discussing $page->optionsfield->has("value=foo") to check if a value was selected, but since this options field might have a bunch of options, it seems a bit much to have to define each foreach. I tried: <?php if($option->has("title={$option->title}")): ?> but I have apparently missed how to do this. Yeah, I really just was not thinking, I got it with: <?php $field = $fields->get('my_field'); $options = $field->type->getOptions($field); $selectedField = $todo->my_field->value; ?> <select> <?php foreach($options as $option): ?> <?php if($option->value === $selectedField): ?> <option value="<?=$option->value;?>" selected><?=$option->title;?></option> <?php else: ?> <option data-id="<?=$page->parent->id;?>" value="<?=$option->value;?>"><?=$option->title;?></option> <?php endif; ?> <?php endforeach; ?> </select>
×
×
  • Create New...