Dynamic route based on the selected page in codeigniter - php

I have a page with a list of all the items. Which is http://localhost/myproject/items
Now I have item details pages which fetch the data from the database based on the item clicked
The url of the item details page is http://localhost/myproject/items/item_detail/3
I want to change the route from http://localhost/myproject/items/item_detail/3
to http://localhost/myproject/items/{item title}
routes.php
$route['items/{item title}'] = "items/item_detail/$1";
How can i get the item title(from database) in place of {item title} in the above code
Please help

Related

wordpress gravity form auto fill/select with current page title

I was wondering if it was possible to make a select dropdown inside a gravity form that can auto select a dropdown item according to the current page that it was loaded in.
For example:
I have 2 pages:
page A
page B
On every page I have the same form (form is made once).
And in that form I have a dropdown with 2 items (page A and page B)
But when I load page A I would like to make sure that the dropdown auto selects page A so that i can use conditional logic.
Ditto for page B.
How can i make sure that this will be possible in a short amount of time?
This is what i did so far:
app.js
e('.button[href^="#"]').on("click", e.proxy(this.openModal, this)),
this.prefillPopup();
prefillPopup: function () {
var i = parseInt(e("body").attr("class").split(" ")[2].replace("page-id-", ""));
e("#input_5_8").val(
{
427: "Personeelsfeest",
429: "Bedrijfsfeest",
431: "Walking en seated diners",
433: "Seminaries & Presentaties",
435: "Productlancering",
437: "Modeshows",
439: "Event op maat",
440: "Activiteiten",
}[i]
);
},
What i did is creating function that when the popup modal is opened/loaded the dropdown will be automatically filled with the data that I want it to be filled with.
The only thing is that it doesn't fill up with the content that I specify.
The dropdown needs to be filled with the desired titled related to the page ID that is being viewed in the browser at that time.

Filtered Table Resetting Laravel 5

I am creating a table that displays a list of customers and their information. I have a few filters that, when selected, modify the table as needed and do so automatically. But when I click the Filter button underneath to save the filters selected and add them to the URL, the URL changes to the correct address but the table returns to the original table. Any ideas how to have the filters not reset when clicking the filter button?

Get the Item id when creating dynamic pages on wordpress

I've been searching for several days now trying to find how to retrieve the item id of a select item from a mySQL database on a wordpress website.
I have a database of several hundreds of recipes. They are all displayed in a list on a certain page. I then want to be able to click on one of the recipes in the link and be sent to a unique recipe.php page.
The list of all recipes is on main-page.php. On this page, I have created the following:
echo '<td class="recipe"><a href=recipe?id='.$id.'><div class="recipe-container"><img src="'.$img.'" id="recipe-image"/>';
echo '<div class=recipe_name>'.$nam.'</a></div>';
As you can see, clicking on a recipe with the id of 4 would send you to www.example.com/recipe?id=4.
My question is, how do I tell the code to recognize that we are on the page for recipe #4, so that I can display its unique details? In particular, what do I write in recipe.php so that I can display the unique content for the selected recipe?
create an onload() event on the recipe.php, then check for $_SERVER['QUERY_STRING'] to retrieve id value and retrieve data from database based on the value
Found the awnser. All I had to do was:
$id = $_GET['id']
Had no idea it would be that easy.

Delete button in Joomla item view in back-end

I would like to place the delete button from Joomla category view in the item view, so that when a user navigates in backend to that item he would be able to delete it.
I tried to move the function of the delete button from category view to the item view but it doesn't work since that function requires a item to be selected. In item view that particular item should already be selected.
You probably want to use something like this:
if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete')) {
JToolBarHelper::deleteList('', 'articles.delete','JTOOLBAR_EMPTY_TRASH');
}
And add a hidden checkbox field in the view with the id variable [i.e. page id] in the view

php search results

I've seen alot of tutorials on search with php and mysql, but im having trouble with generating a link with the search result. For example say i have an item called "item1" in my db and the user searhes for item , item1 should be returned as a link so the user can click the link to get more information about that product. Does anyone have any scripts , or snippets of code for how to acheive this?Thanks
You probably need to create an item page say item.php that accepts an id which will then search teh database for that item and display the item information.
Your search results will then have to display the name of the item in a link that also includes the id of the item.
<?php echo $itemname"?>
This would of course be in a loop that goes through the list of items one at a time.
When the user clicks the link it will take them to item.php and send id as a parameter.
that's a simply example with no check and no control by datatype or query results. just start from it and do what you need...
<?php
//your db connection
//col1 is where the id is saved
//col2 is the url
$qry="SELECT col1, col2 FROM table WHERE col1='".$_GET['var']."'";
$result=mysql_fetch_array(mysql_query($sql));
echo 'LINK';
?>
edit:
if you want a direct redirect do this instead of echoing
header('Location: '.$result['col2']);

Categories