Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by maxxd

  1. I got a message with the actual code we've requested here... OP - if you want help with the task, post the code here and let all of us take a look at it. More eyes = more help, but remember this is your homework. So we will help, but we won't write it for you.
  2. Think it through. One of the things you'll see and hear about regularly in programming is 'pseudo-code' - write the steps you need the program to follow in order to solve the problem, then write the code to actually do it. So what do you need to do here? for the first 50 units of energy energy used add .10 to the total bill are there units left to bill? for the next 100 units of energy used add .15 to the total bill are there units left to bill? for the next 100 units of energy used add .25 to the total bill are there any units left to bill? for the rest of the units add .35 to the total bill take the total bill and mulitply it by .2 to figure the VAT add the VAT to the total bill output the total bill You need to look at conditional logic and math functions. There's a bunch of different ways you can do this, so write some code and post it here. If your throws errors post those, too.
  3. This means that the return value of PT_Secure($_GET['page']) is always 'category'. The problem is with PT_Secure() - check the documentation to make sure it's being used correctly.
  4. If you're visiting the 'trending', 'latest', and 'top' pages and seeing 'HELLOcategory text here' on all three (or any of the three, actually), then something is wrong with either PT_Secure() or your use of it because the value of $page is never not 'category'. Change die("<pre>".var_export($page, true)."</pre>"); to print("<pre>".var_export($page, true)."</pre>"); then visit the 'trending', 'latest', and 'top' pages and compare the output.
  5. The goal has been achieved. The script is doing exactly what you've said you wanted - you're printing custom text on each of the three specified pages; you're just not testing from one of those three pages. If you need custom text per page and don't want to limit it to the three listed pages, you'll have to account for those pages in your conditional logic.
  6. Change this $text = ''; $category_id = ''; $videos = array(); to die("<pre>".var_export($page, true)."</pre>"); $text = ''; $category_id = ''; $videos = array(); and see what it says.
  7. You're assigning a value to both variables, then sending both variables to PT_LoadPage(), where you print both out. So by showing both, your code is actually doing exactly what you're asking it to do. You've already got some logic to determine the page. Inside those logic blocks, you can set a value to $text that is specific to that page. Then only include $text as a parameter of PT_LoadPage(). That way, you'll know the variable is set no matter what page you're on but it'll be populated with page-specific data. You could also continue the way you're going and look into template conditional logic tags, but at that point you're mixing your logic and display code to an extant that's - IMO - missing the point of using a templating language anyway.
  8. I think the way you're doing it is not a bad solution. Grab an array of the IDs (select only the ID in order to make it a quick query) at first page load on initial visit to the site and store that in session or a cookie - it's not like the historical air date is going to change, so the data doesn't need to be all that fresh, honestly. Then you can grab the next or previous episode by the episode ID from the previously set and stored array.
  9. If your host provides cpanel, try the Metrics > Errors log. That may point you in the right direction.
  10. Yes. Depending on how everything is set up and when and where the function is defined you may have to pass jQuery to the function, but it's easily doable. For instance (and please note it's late and this hasn't been tested so ... you know, look up the functions but the idea is solid) this: $('#mycontrol').on('click', function(e){ e.preventDefault(); $.post({ // ....etc etc... }); });
  11. OK - I've been beating my head against this for a bit now and I give up... I've got a vagrant box up and running on my host system. I'm using gulp with several node modules from the host system, and everything is working well except browser-sync. My directory structure (abbreviated): /dev /_assets /javascript /less /build /templates gulpfile.js package.json Here's the code so far: const _ = require('lodash'); const aw = require('gulp-load-plugins')({ pattern: ['*'], scope: ['existingDevDependencies'] }); aw.browserSync = require('browser-sync').create(); const pkg = require('./package.json'); var themeName = pkg.name.toLowerCase().replace(new RegExp(' ','g'), '-'); aw.gulp.task('Develop', ['browserSync', 'developJS', 'compileCSS', 'watch']); var theme = { srcJS : '_assets/javascript/**/*.js', srcCSS : '_assets/less/**/*.less', srcStyle : ['!_assets/less/variables.less', '_assets/less/style.less', '_assets/less/**/*.less'], destJS : pkg.directories.content + '/js', destCSS : pkg.directories.content + '/css', }; /** * Set up the browser reload on the host machine when the files are updated */ aw.gulp.task('browserSync', () => { aw.browserSync.init({ proxy: "vagrant.craft.internal", host: "vagrant.craft.internal", open: "external", port: 80, }); }); /** * Development JavaScript handling. * Browserify, Babelify, and uglify with in-line sourcemapping */ aw.gulp.task('developJS', () => { "use strict"; _.forEach(_.castArray(pkg.scripts.entry), (script) => { aw.browserify({ entries: ['./_assets/javascript/' + script + '.js'], debug: false }) .transform(aw.babelify, { compact: true, retainLines: false, comments: false, }) .bundle() .on('error', handleError) .pipe(aw.vinylSourceStream(script + '.min.js')) .pipe(aw.vinylBuffer()) .pipe(aw.uglify({ sourceMap: { url: 'inline' } })) .pipe(aw.gulp.dest(theme.destJS)); }); }); /** * During development, obviously we want the system to watch for any * important changed files and to handle those automatically. */ aw.gulp.task('watch', ['browserSync', 'developJS', 'compileCSS'], () => { "use strict"; aw.gulp.watch(theme.srcCSS, ['compileCSS', aw.browserSync.reload]); aw.gulp.watch(theme.srcJS, ['developJS', aw.browserSync.reload]); aw.gulp.watch('./build/templates/**/*.html', aw.browserSync.reload); }); /** * Production and Development .less processing * Processes the .less to CSS, then minifies the file. * Note that grid support is enabled and we're bablifying * back to IE10. This should change in the very near * future as we drop support for 10. */ aw.gulp.task('compileCSS', () => { "use strict"; return aw.gulp .src(theme.srcStyle) .pipe(aw.plumber(handleError)) .pipe(aw.less({ strictMath : 'on', strictUnits : 'on', })) .pipe(aw.concat('all.css')) .pipe(aw.autoprefixer({ browsers: [ "last 2 versions", "IE 10" ], grid: true })) .pipe(aw.cssmin()) .pipe(aw.rename({ extname : '.css', basename : 'style' })) .pipe(aw.gulp.dest(theme.destCSS)) .pipe(aw.browserSync.stream()); }); browserSync initializes just fine - my browser opens, loads http://vagrant.craft.internal and my terminal shows the proper Local, External, UI, and UI External addresses. I update my .less, .js, and .html files and my terminal says 'Reloading Browsers'. But there's no browser reload...
  12. I'm totally confused - you say in the OP that a problem is that " it won't hide those previously refunded entries. ", but you need to see the previously refunded entries? I'm not getting it, so I'm gonna bow out in an attempt to lower the signal-to-noise ratio...
  13. Chances are very good, yes. However, it's going to depend on how the tables are structured. I'm assuming there's a way to tell refunds from sales in your database - use that as your JOIN criteria. So, basically, when joined on transaction ID.
  14. This sounds like a data gathering issue. I assume the data's coming from a database and includes a transaction ID and transaction type, yes? Would it be easier to pull transaction type sale without a corresponding refund transaction type - I'm sure there's additional business logic to be considered, but it seems to me it'd be easier than pulling everything and culling data you don't want from that.
  15. I'll admit, given that you could handle assigning a value to a variable and reading a value from a form element, I honestly just kinda assumed you'd be able to extrapolate assigning a variable value to a form element. Kicken's example should work for you - follow Barand's advice and tear it apart. As to the question of doing the data manipulation on the server-side, it depends on what you're doing and how you're comfortable doing it. The world is moving to a place where online applications act and feel like desktop applications, so getting comfortable with asynchronous functionality (AJAX and fetch) will serve you well in future development. However, if you're not familiar or comfortable with JavaScript (or any of the umpteen bazillion JS frameworks that are out there now) but feel good with PHP, do it on the server side. It'll get the job done and give you more time to explore other processes and solutions.
  16. I'll just leave this here again (I added the emphasis). You need to change the value of the field before you submit the form. Or follow kicken's suggestion to do the data modification on the server side in PHP. Or use the jQuery Datepicker widget and avoid all these issues you've been banging your head against for several days now.
  17. Again, are you setting the value of #birthday to the computed date before you submit the page? If not, the processing script will have 'birthday' in $_POST['birthday'] because your validation script doesn't change the value of the field.
  18. I'd give http://api.jqueryui.com/datepicker/#method-getDate a shot - it should at least put you on the right track for this. http://api.jqueryui.com/datepicker/#option-yearRange You're already running a complete page refresh on form submit, so I don't really see where this would become an issue for you. And again, you could format the date string in PHP before it's output to the page, thereby negating what appears to be a pain point for you.
  19. Legit. However, you can use jQuery's datepicker with drop-down month and year selectors to make this easier. To the question at hand, you say you're getting the date from a drop-down menu. How is that built? Seems to me it'd be easiest to add the leading zero on the value attribute (not necessarily the display text) during form compile rather than during validation and/or submission. As to your question about the validation, it depends on how you're submitting the data to the controller script. If you're submitting via AJAX from JavaScript, make sure you're passing the 'birthday' variable you've built in that snippet. If you're doing a full page refresh, assign the value of the 'birthday' variable to the hidden input before submitting the form - otherwise whatever script is processing the form data is getting the data from the hidden form field and not the JS variable.
  20. Is there a reason you're not using a datepicker? I know the jQuery DatePicker has formatting options and I have to assume other native/node/ESx datepickers do as well. It'd certainly be easier than prepending zeros to combobox values everywhere.
  21. I'm pretty sure - though I could be wrong - that rem and em take browser zoom into account, so if I'm right that could be another thing to look at. Although requinix is correct - the entire point is to make the font bigger. It can be pretty safely assumed that people that use the zoom functionality know they're messing with the designer/developer intent of a site and are OK with it. Kinda like turning off JavaScript in your browser - you do it and you pretty much forfeit the right to complain about site functionality (now days, anyway).
  22. You would simply pass the database query results (or portions thereof) to the function that outputs (or collates the data for) your form. It certainly doesn't need to be a global variable, unless I'm misunderstanding what you're asking. Post the code you're working with and we'll all have a better idea of what's going on.
  23. Add $mail->SMTPDebug = 2; before you try to send the mail. It'll give you a lot more detail as to the error that's happening.
  24. .innerHeight() is working in tests here, unless I'm misunderstanding what it is you're wanting.
  25. First and foremost, you've got some serious syntax issues, especially this line: list += '<li">'+this.id+' '+this.name</li>'; You see where your nested quotes are all over the place and you're missing the concatenation before the closing <li> tag? You'll need to correct that to begin with. Moving on from that, I'm not quite sure what you're trying to do. It sounds like you've got a list and want to select individual elements of that list using back and forward buttons? If I'm correct in that assumption, you'll want to build the list before you call your click() function. Personally, I'd build the list with 'data-index' and 'data-selected' attributes on each list item element. That way, when you click the next or previous button you can grab the data-index value of the data-selected="true" list item element, add or subtract one from it, target the list item element that has a matching data-index value and set it's data-selected attribute to "true". You'd obviously have to set the previous list item element's data-selected attribute to "false" at the same time. That way you really don't have to worry about keeping an index in the JavaScript.
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.