Finding the right PHP file to edit - php

This post follows research and another recent SO post. That question was along the lines of "Is there a way on any PHP site to identify the file that contains the html that you are viewing on a webpage?" Using, for example "inspect element" feature.
It appears not. Fine. Is there a conventional way around this? From research it seems it's a security issue so with PHP you cannot.
I can login to the host using Filezilla. I want to edit my main Navigation menu. I'd therefore like to search for something like Nav, Navigation, Main menu etc but there does not appear to be a search feature along those lines.
What do developers typically do here (I am very new to PHP). How does one typically identify a file to make edits when they are working on a site that they did not create?

This might help: go into the source and find beginning of the specific piece of HTML generated for your navigation. It might be (I'm not including the closing tag because that might be generated dynamically):
<nav id="main"
or
<ul class="navigation"
Get something like Sublime Text and drag the project folder into it. Then do Find -> Find in Files (Ctrl-Shift-F) and search for that snippet of HTML.
Hopefully you should find what you're looking for.

Related

Some elements missing / changed when trying to change from html to php

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.

link to id on page but reposition

I've used a modified themeforest template for a single php page and have an issue where the navigation links that take you to the various unique id's on the page are working fine but cut off the top part of the section h3 that it has linked to.
It's a positioning problem for sure and most likely to do with the modifications I made to the flex-slider that the template included.
But I can't determine how to adjust the css (or script) to correct the issue.
For example, the site is http://goudkamp.stacklaw.com.au/ and when you click Services, you can see what I mean.
I have the template on the site as well so you can see how it SHOULD work - http://goudkamp.stacklaw.com.au/v2/template/.
I came across another article that suggested using the script
if(window.location.hash.length){
$(window).scrollTop($(window).scrollTop() - 100);
}
However, I don't think I should need it when the template works perfectly.
I just don't know where to start looking to make the necessary adjustments.
Please help!
Thanks in advance
Wait - I found it!
After looking at the suggestion on the other article, it made me think that it must be done in the theme's custom scripts. So I looked in the custom.js file for any script that referenced the main nav.
There was an "offset" line with the markup "//use this to position the window exactly where you want". Testing a small change to this had the desired effect.
Thanks anyway.

Need to modify a Wordpress Homepage template to include ignored contents of editor field

I am attempting to tweak an existing Wordpress theme called Pytheas (for a quickie video tour of its features, visit this page). It is a WP theme oriented toward displaying portfolios. The homepage features a slideshow. My aim is to replace the slideshow with an embedded Prezi presentation.
The home page elements are (moving from top to bottom): header, menu, slideshow, tagline, highlights, posts. However, the Homepage is an odd little thing. It omits any content you may have typed into the editing window (instead, using only the images that have been uploaded to another dashboard section).
I have confirmed that the Prezi-Embedder plugin works on standard style default, blog, and pages. My presumption is there’s some CSS element at work.
My gut (and a little sniffing around) says that this bit of CSS (from template-home.php) may play a role. Specifically clearfix:
<div id="home-wrap" class="clearfix">
<?php
//get template path
$template_path = get_template_directory();
//show tagline if setting isn't empty
if(of_get_option('home_tagline')) { ?>
<div id="home-tagline" class="clearfix">
<?php
//tagline content
echo of_get_option('home_tagline'); ?>
</div>
This is where I turn to you, StackOverflow community members. What might I do to provide additional data and/or context?
Many thanks, in advance, for your attention.
Matt Warren
First step was to verify that the slideshow content was indeed being output to the final HTML. After verifying this, I moved on to the one JavaScript error being displayed:
Uncaught Error: Syntax error, unrecognized expression: a[href$=.mp3]
A quick Google on the full error seemed to confirm suspicion that this error was killing the rest of your site's JavaScript, and thus causing your slideshow to not work.
So the idea now (without being able to see all your installed plugins) was, you had some plugin that was installed to playback MP3 files. So that's where I pointed you for a possible fix. The link above provided a potential fix for an installed plugin causing this issue, but simply installing a new audio player was another valid, and less technical, solution.
I was only able to help you by actually seeing the site, that would have likely been pertinent information to provide to get additional feedback from the community.
Glad you got it resolved!
I reached out to a colleague of mine who's more skilled in the php/css dark arts. He was able to confirm that clearfix was not the issue. I was way off. However, his tinkering got some neurons firing and he snooped for a while.
Using Chrome's built-in developer tools, he was able to determine that I was experiencing the same javascript error (which was invisible to me) as this person.
In that thread, one zoonini offere another link to a solution she used. The money is here:
Search for href$=.mp3 and replace by href$=".mp3"
From what I can gather, this is the rub: For whatever reason, pre-HTML5 embedded-audio plugins can fluster these newfangled adaptive themes (oooh, did I use a buzzword?). I fiddled with the javascript file, couldn't resolve the problem and said "to hell with it."
My solution was to uninstall WPAudio and install Haiku Minimalist Player (which is HTML5 and doesn't interfere with such theme elements).
Not only does this make my embedded Prezi displayable, it allowed my frontpage slideshow (which didn't work to begin with) to work properly.

Find the PHP/HTML file containing DIV container shown in FireBug

I'm editing an existing template in Joomla and I need to change the menu icons text. In Joomla Administrator, I cannot find the place where I can do this. So, in FireBug I found DIV container that I was searching for. But if I change the text in FireBug, my changes are obviously not saved. Now very basic question is: how can I know the name of PHP or HTML file, where this DIV container is located? Or how can I save my changes?
FireBug will only change web browsers content, it will not affect files on the server. If you know DIV's id you can search for files with this string on the server. To save changes - edit file and save - but on the server.
I use TestWrangler app (I'm on a mac) - open blank TW, click on Search, browse to target a folder to search through. I always search through a copy of my website folders on my hard drive rather than live site files. Search for the text string you're wanting to find which file contains it. Give TW a few seconds or more and it will tell you exactly which file contains the string.
http://www.barebones.com/products/textwrangler/
When you right click on an HTML element and select "Inspect with firebug", on the right hand side of the firebug screen you will see the styles applied to that element, and where it says the line number, if you just hover your mouse over it it will show you the exact location of the file.
Use a file search tool, it is included in most IDE's, if your editor doesn't have such a feature try a file grep tools like wingrep (http://www.wingrep.com/)
I just thought I'd share this as a possible 'answer' as well.
there is a joomla extension that enables you to search through your source code within joomla itself.
Here is the link:
http://extensions.joomla.org/extensions/miscellaneous/development/22858
I'm sure it will come in handy instead of going through the hassle of a complex setup on localhost.

Prestashop - custom template link

I'm starting with "PrestaShop" and I just can't figure out, how to put a link in template to custom page I created in CMS module... I thought, there might be some easy way, as there is in WordPress, like "get_permalink(ID)", but there's nothing like this and I can't find anything about this anywhere and it just drives me mad.
So, here's the deal, I've got a custom template, and there are some top links, like "About Us". I've created this page in CMS and it has ID "6".
How do I make this bloody "PrestaShop" to generate a link to this page in my template file?
About
I think you're looking for SMARTY template tags and custom variables defined for Prestashop specifically. The one the you probably need is {$base_dir} which will be translated to http://www.yoursite.com/ obviously with appropriate protocol (non-secure HTTP or secured HTTPS).
After that, you only need to include page URL, which you can get from Admin->Tools->CMS section.
If I find any specific tags that you can use to call the content, I will update my post here.
Your Text
the "WHAT goes here" is just the url you want your link drives the client to when clicking on that link.
You need to understand a little minimum of HTML for this I guess. Check html tag a meaning .
Prestashop has a fairly good and extensive documentation. Two and half seconds googling drives me here, just like answering your question it looks like.

Categories