The requested URL was not found on this server. - php, wordpress - php

I have the following folder structure on my local -
xampp\htdocs\wordpress\wp-content\themes\mdbblog
on my local and under this directory, have following files -
I activated mdblog theme from http://localhost/wordpress/wp-admin/ and able to access the index page of my site http://localhost/wordpress.
The problem is I am unable to href any other page from home page.Following is my code to access Gallery in the menu -
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="navbarDropdownMenuLink" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">Gallery</a>
<div class="dropdown-menu dropdown-primary" aria-labelledby="navbarDropdownMenuLink">
<a class="nav-link" style="padding:5px 10px;" href="./clinic-gallery-page.php">Clinic </a>
<a class="nav-link" style="padding:5px 10px;" href="patients-gallery-page.php">Patients</a>
</div>
</li>
When I click Clinic, I get following error -
I have no clue as what am I doing wrong here. I new to PHP and Wordpress. I also don't see any pages present under mdblog theme on admin. Is that expected? Any help is much appreciated.

Ok, sooo WordPress isn't exactly a file request type system.... WordPress will only resolve based on your db... Read te docs or ask more direct questions. I advise you:
Create a page. .. this pages will register a route (sortoff) on your db
Assign that page to your menu
Big warning. When you create a localhost page on development, this will be written like that on your db. When you take this to a production server, you will end up with some links as localhost and some as the domain. U will either always have to redirect, or before you upload your db to production, you can dump the sql, and do a find localhost and replace with your new domain on notepad ++
Unless you are creating your own theme. I wouldn't add files directly to your theme as it can be overwritten on an update. Create a plugin.

Related

Changing .active class and aria-current="page" dynamically based on active webpage

I'm building a website while also trying to keep changing code an easy task.
For that, I include the navbar with <?php require_once('./includes/navbar.php'); ?> so that I only need to change the navbar.php to see changes site-wide.
I also use Bootstrap 5 and let it take care of styling the currently active page by using <a class="active"> (and also using the recommended aria-current="page" attribute).
Now my problem is that I need to somehow dynamically apply the above mentioned class and tag to only the active page. I have no idea how to do that in an elegant way but thought that this might be possible in PHP?
Does somebody know how to do it?
Click here to see code of the navbar
I did some research and managed to fix my problem with a little bit of javascript code which you can just add with <script></script> tags anywhere in the html code:
Give every link in the navbar html a unique id (e.g. id="pricing").
Add class="active" to active page and Bootstrap.css will style that element accordingly.
Remove class="active" from the other pages/links which are not active.
Set aria-current="page" to active page and set aria-current="none" to inactive pages.
in navbar.php:
<a id="home" class="nav-link active" href="index.php">Home</a> <!-- 1. -->
<a id="pricing" class="nav-link" href="pricing.php">Pricing</a> <!-- 1. -->
in pricing.php:
<script>
var pricing = document.getElementById("pricing");
pricing.classList.add('active'); //2.
pricing.setAttribute("aria-current", "page"); //4.
var home = document.getElementById("home");
home.classList.remove('active'); //3.
home.setAttribute("aria-current","none"); //4.
</script>
Hope this may help someone else too.

How to solve the route changing to another when I make a scroll to the section of the same page in Laravel 8?

I am using blade template for laravel and I want to make a navigation link that scrolls to the section of the same route.
Here is the code example...
<li class="nav-item">
<a class="nav-link" href="#ask_for_help">Ask for Help</a>
</li>
<div id="ask_for_help">
The section that I want to reach.
</div>
It did reach to this section, but the route changes to
localhost:8000/#ask_for_help
instead of staying at the same route
localhost:8000

Change page and URL without refreshing the Page

Hi and I'm terribly sorry for asking such question.
I'm quite catching up on Laravel, maybe 30% smarter than before but I'm stuck on this kind of scenario.
How do I call a blade with all parameters passed to its controller without refreshing the page.
Here's my folder structure (I will not place all just controller, pages)
Folrder Structure
Now, I'm in let's say dashboard.blade.php
In the Side bar of my dashboard I want to go to a link
<li class="nav-item">
<a href="{{url('/get-greeting/{id}/{user}')}}" class="nav-link get-greeting">
<i class="nav-icon fas fa-table"></i>
<p>
Requested Son
<span class="right badge badge-danger side-span requested-span"></span>
</p>
</a>
</li>
Route will be
Route::any('/get-greeting/{id}/{user}', 'DefaultController#pullGreeting')->name('getgreeting');
Controller will be
public function pullGreeting($id, $user){
$userName = User::activeUser($user);
$defaultarray = array( 'greetingLogs' => recordLogs::pullgreetings($user) );
return view('pages/department1/greetings',$defaultarray);
}
When I click it, it refreshes the page. Anyone, can you help me and pinpoint where am I doing wrong so I can make it not refreshing the page but instead changing the blade dynamically?
Does this matter?
return view('pages/department1/greetings',$defaultarray);
or
return view('pages.department1.greetings',$defaultarray);
PHP is a server-side programming language therefore any changes to the view will require a full page refresh.
Without the use of Javascript, achieving a part page refresh would require the use of an old school technique called Frames.
You could redesign your application to render HTML via different endpoints and have a Javascript powered frontend that calls to those endpoints.
You could easily achieve through the use of JS Libraries such as React or JQuery.

Having trouble redirecting using 'Common' navbar in PHP website

Im creating website using PHP for the backend. I created a "Common" folder that stores my navigation bar that i'll be using throughout the application. In the navigation bar there are links that redirect users to different pages of the website.
The pages the user will be directed to are in different folders and subfolders of their own. When i click on the navbar link, it redirects to the page. Thereafter, when i click on another navbar link from that page i get a "Object not found" error.
These are the main links:
<li class="nav-item">
<a class="nav-link" href="Views/view_Catalogue.php">PRODUCTS</a>
</li>
<li class="nav-item">
<a class="nav-link" href="Views/view_BecomeCustomer.php">BECOME A CUSTOMER</a>
</li>
<li class="nav-item">
<a class="nav-link" href="Views/view_MakeAnOrder.php">MAKE AN ORDER</a>
This is the include of the pages:
<?php
include('../Common/Header.php');
include('../Common/NavigationBar.php');
?>
These are the file directories:
https://i.stack.imgur.com/p9dA7.png
https://i.stack.imgur.com/wrp5S.png
These are the URLs and before and after i get the error:
Website starts on the index page:
myphp/Ticototrading/index.php
When i click a link it redirects the user to:
myphp/Ticototrading/Views/view_BecomeCustomer.php
And then, when i click on the home link(or any navlink) on the navbar again i get the "Object not found" error and i noticed the problem lies with the file path that has changed to:
myphp/Ticototrading/Views/index.php
When I redirect to a different page, the current page adds its folder to the file path instead of going directly to the href="" given.

Facebook share not working in subdirectory wordpress

i have two wordpress sites, one in root and another in a subdirectory, named fr.
For the wordpress in the root directory the facebook share is working fine, but in case of subdirectory its not working.
here is my links
https://www.acanac.com/blog/general-category/your-go-to-halloween-safety-and-party-blog/ - Working fine
https://www.acanac.com/fr/blog/general-category/votre-blogue-de-reference-sur-la-securite-et-les-fetes-a-lhalloween/ - Not working
This is the code i am using in my site.
<a onClick="window.open('http://www.facebook.com/sharer.php?s=100&p[title]=<?php the_title() ?>&p[url]=<?php the_permalink() ?>&p[images][0]=','sharer','toolbar=0,status=0,width=580,height=325');" href="javascript: void(0)" class="" title="" href=""><i class="fa fa-facebook icon"></i></a>
Can any one please help me..... Thank you in Advance.

Categories