I'm currently generating a long page using PHP. The page also requires parameters:
http://host/showFile.php?file=abc
The resulting page can be quite lengthy and I would like to extend this to position the page at a specific line. I know how to do this using and adding #tag to the URL for an HTML file, but I can't see how to combine the effect in this case. Putting
http://host/showFile.php#tag?file=abc
doesn't work, as PHP doesn't see the file= argument, putting
http://host/showFile.php?file=abc#tag
also doesn't work as it assumes the file is then abc#tag.
I could put:
http://host/showfile.php?file=abc&line=tag
and change my code to start at the required line, but this would only show the page from the required point onward, and I need to have the whole file viewable by scrolling back.
Any ideas?
Thanks, Bill
Related
I'm asking for help for those who have experience in changing an html file to a php file. I've tried everything I know (and I'm not the smartest I admit) but I don't understand why the following is happening.
Currently: When viewing on mobile, the mobile menu button has gone, the toggle switch which changed prices from monthly to annually, tabs which displayed different content has gone. As a result:
If there was a toggle, both the toggle results are displayed one above the other
If there was a tab, each tab element is displayed underneath the other
The mobile menu button has gone completely
Background:
I purchased an HTML template but it turns out the seller didn't want to help. I wanted to split and convert the page into a php page as I wanted a single header/footer file which I could import. As you will see (if you check the repo) the header.php and footer.php file is getting imported into the page php file.
I created the pages by first:
Renaming the original html file to a php file
Cut the header and footer and import them back into the page php file
That's all I have done. It seemed to work, however another check (after cache cleared) I noticed the issues.
The link to the site page im referring to is:
https://blueboxhosting.co.uk/products-cloud-hosting
But if you look at any of the pages, you'll see errors on all of them now where they're should have been controls (eg toggles, mobile menu, tabs etc)
I've created a snipped so you can view the code and HOPEFULLY spot where I've been a moron:
https://bitbucket.org/snippets/bbhostinguk/7e5qxp
Any help with this would be amazing as I just can't figure it out.
Start by running the HTML generated by PHP through a validator, e.g. https://validator.w3.org/
Your code has numerous stray tags which may or may not affect the rendering.
Another tip is to comment off everything and then uncomment section by section and check when things start to break.
I'm working on a website, that was done by someone else previously. Owner didn't end up with previous dev on a good terms and I cant contact him now with questions.
For most of part, code is a regular PHP. However, in some places I see weird tags that I cant recognize.
for example:
<php:dropdownlist:ddlTypeOfResidence></php:dropdownlist:ddlTypeOfResidence>
The code above, generates the dropdown with values. I don't understand how to read this tag, on the sidebar, they have the get a quote form, and I need to add this field on that sidebar form. I copy pasted the line given above, and it works only on pages, where the original form exists that includes that line as well.
Example, page freeQuote has a form, and on that page on sidebar, get a free quote mini form is also displayed. On this page, input field gets the values dynamically, so that TAG works on this page...
On the other pages, where the original full form is not loaded, this dropdown is still displayed on the sidebar mini form, however, the values are empty.
Anyways, before everything else, I need to understand what language / tag is that, how to read it.
I believe it is a basic XML converter. The below code is actually a XML code:
<php:dropdownlist:ddlTypeOfResidence></php:dropdownlist:ddlTypeOfResidence>
What it does is: It parses php:dropdownlist:ddlTypeOfResidence string using .split(':') and does the needed functionality accordingly.
This is a template engine that change some tags into native PHP renders.
I don't know if it's a regular engine ( maybe a custom engine ), but most powerful and simple PHP engine is Smarty. ( This isn't Smarty )
You can look at the PHP codes hope that you find the engine.
Good Luck
I'm using http://simplemvcframework.com and I want to link to a section on a page normally you will just add something link
#section4
to the end of the URL but this doesn't work as expected, it doesn't jump to the correct section of the page. I'm suing the following format to try and achieve this:
/controller#section4
Do I need to pass the view into the link somehow? possibly something along the lines of
/controller/viewname.php#section4
I have never used that framework before, but anchors are handled by the browser, and don't even get sent to the browser.
(I.e. when accessing /controller/#section4, the server only receives /controller/.)
It looks like you don't know about the actual use of # in URLs:
Upon loading the page, the browser will look for an element on that page with an id or name (for backwards compatibility) matching the part after the #.
So you probably just want an element with id="section4" on that page.
If you need HTML 4 support, you have to put <a name="section4">...</a> around your anchor to achieve the same effect.
(See also this question.)
I want to load pages from PeoplePerHour.com into python to run some data analysis, but it keeps getting data from a page I didn't ask for, I think it must go to the main page and then refreshes somehow into the page I ask for.
For example:
I want to pull the prices from all users at http://www.peopleperhour.com/freelance/data+analyst, and the data spans over multiple pages.
Say I want to request page 2, http://www.peopleperhour.com/freelance/data+analyst#page=2. If I go here in a browser, it works fine and pulls up page 2, but I think it pulls up page one first and then "refreshes" into page 2 (I think). If I access this in python, it loads the HTML from the first page, and never sees page 2.
Here's my code:
import requests
from pattern import web
import re
import pandas as pd
def list_of_prices(url):
html = requests.get(url).text
dom = web.DOM(html)
list = []
for person in dom('.freelancer-list-item .medium.price-tag'):
currency = person('sup')
amount = person('span')
list.append([currency[0].content if currency else 'na', amount[0].content if amount else 'na'])
return list
list_of_prices('http://www.peopleperhour.com/freelance/data+analyst#page=2')
No matter what, this returns the prices from page 1.
What is going on that I'm just not seeing?
If I understand correctly, you want to iterate through the pages. If that's the case, I believe the problem is with your URL.
Here's the URL you gave:
http://www.peopleperhour.com/freelance/data+analyst#page=2
The problem is, "page" is not a bookmark on that page. When you use the #page=2, it tells the browser to go down to the same page for a bookmark called "page=2".
Here's the URL for the Next button in that site:
http://www.peopleperhour.com/freelance/data+analyst?sort=most-relevant&page=2
You'll see it says "&page=2" which means something else. In their code "page" is a variable being passed via the url, with a value of 2. You use the "&" if there are more than one of these variables. Also, you are missing a "?" symbol. If you're passing variables via the URL, you have to put a ? followed by the name=value pairs for your variables.
So, easy fix, change your url to this:
http://www.peopleperhour.com/freelance/data+analyst?page=2
That's in comparison to your old url:
http://www.peopleperhour.com/freelance/data+analyst#page=2
As a quick test, copy/paste the corrected url on your web browser. You will see it now is on page 2.
Getting dynamic content (those generated by client-side code) is always very tricky. There is no easy solution to this, but if you really want to dig into it, I recommend PyV8, a JavaScript engine in Python.
Error in pattern when using pattern3 in python 3.6
Please click on the above Hyperlink to open the Image
What is the alternative to executing the same code under python3.6 environment because due to this I have to install the pattern3, the pattern is not supported by the python 3.6
Thanks!
In part of a web page, I currently link to a part of the webpage using . In other words, I link to something like:
Link 1
However, on that same link I want to include a PHP variable, which would normally look like
Link 2
Combining the two in either order just makes the page refresh, neither scrolling properly or taking the php variable. How can I use the two simultaneously?
You can concatenate the two together, just put the hash last because that is not sent to the webserver (it will be used by the browser to jump to a certain part of the page):
Link 1
When you're on the same page as the URL in your anchor, regardless of #'s value (It's called the "fragment"), the page won't even refresh, it will scroll up in hope to find an anchor that has the fitting name for the fragment
The URL fragment (everything behind # at the end of an URL) is a client-side thing, PHP won't be able to do anything with it