|
have a tree menu(category,subcategory,sub-subcategory...) its all in a single table and uses parentID to determine layout of the menu. would like to now be able to update the menu by adding new menus(not on the server side). have a dropdown list of the menus where you select the parent from existing menus from the table(if you select none,then creates a new category in the table else inserts under matching parent based on parentID).need help parsing the selection from drop down menu to the parentID column in the table. am new at this so hope my question makes sense.
Reggie
|
|
|
|
|
Use PHP and angularjs to generate dynamic menu.
1.php service read your data send response in json format.
2.Angular app init with menu item.
your html code like (menu.html)
<pre>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<style>
*{
margin ;
padding ;
}
body{
font:15px/1.3 'Open Sans', sans-serif;
color: #5e5b64;
text-align:center;
}
a, a:visited {
outline:none;
color:#389dc1;
}
a:hover{
text-decoration:none;
}
section, footer, header, aside, nav{
display: block;
}
/*-------------------------
The menu
--------------------------*/
nav{
display:inline-block;
margin:60px auto 45px;
background-color:#5597b4;
box-shadow 1px 1px #ccc;
border-radius:2px;
}
nav a{
display:inline-block;
padding: 18px 30px;
color:#fff !important;
font-weight:bold;
font-size:16px;
text-decoration:none !important;
line-height:1;
text-transform: uppercase;
background-color:transparent;
-webkit-transition:background-color 0.25s;
-moz-transition:background-color 0.25s;
transition:background-color 0.25s;
}
nav a:first-child{
border-radius:2px 0 0 2px;
}
nav a:last-child{
border-radius 2px 2px 0;
}
nav.home .home,
nav.projects .projects,
nav.services .services,
nav.contact .contact{
background-color:#e35885;
}
p{
font-size:22px;
font-weight:bold;
color:#7d9098;
}
p b{
color:#ffffff;
display:inline-block;
padding:5px 10px;
background-color:#c4d7e0;
border-radius:2px;
text-transform:uppercase;
font-size:18px;
}
</style>
<!-- Adding the ng-app declaration to initialize AngularJS -->
<script type="text/javascript">
var menuApp = angular.module('menuApp', []);
menuApp.controller('menuCtrl', function ($scope,$http) {
$scope.active = 'Blog';
$scope.description = ''
$scope.menuList = [
{
'name': 'Home',
'description': 'Home page.'
},
{
'name': 'Projects',
'description': 'projects page.'
},
{
'name': 'Services',
'description': 'services page.'
},
{
'name':'Contact',
'description':'contact page.'
}
];
$scope.activeMenu = function(menu){
$scope.active = menu.name;
$scope.description = menu.description;
};
$scope.loadMenu = function() {
$http({
method: 'GET',
url: 'menu.php' //url contain your php service which return data in json format
}).success(function(data) {
$scope.menuList = data;
}).error(function() {
});
}
// $scope.loadMenu();
});
</script>
<div id="main" ng-app="menuApp">
<!-- The navigation menu will get the value of the "active" variable as a class.
The $event.preventDefault() stops the page from jumping when a link is clicked. -->
<div ng-controller="menuCtrl">
<nav class="{{active}}" ng-click="$event.preventDefault()" ng-repeat="menu in menuList">
<!-- When a link in the menu is clicked, we set the active variable -->
<a href="#" class="{{menu.name}}" ng-click="activeMenu(menu)">{{menu.name}}</a>
</nav>
<!-- ng-show will show an element if the value in the quotes is truthful,
while ng-hide does the opposite. Because the active variable is not set
initially, this will cause the first paragraph to be visible. -->
<p ng-hide="active">Please click a menu item</p>
<p ng-show="active">You chose <b>{{active}}</b> </p>
<span ng-show="active"> <b>{{description}}</b></span>
</div>
</div>
</pre>
//your ajax call get response from php service while page load and populate your menu as per your choice.
|
|
|
|
|
Hi guys;
I've been trying to come up with a way to build an automated PHP transfer system between 2 servers.
Server A : only ftp access; server B : ftp access and can run php scripts.
I want to copy all file in server A to a folder in server B;
Here is what I am trying to do :
1: function compress_each_ftp_folder_or_file_in_ftp_Backups_folder();
2: function delete each_ftp_folder_in_ftp_Backups_folder_after_successful_zipping();
3: function download_each_archive_in_ftp_Backups_folder();
4: function delete_each_archive_after_successful_download();
I have written some scripts for step 2, 3 and 4 but nothing found on web that help me with step 1;
I found lot of codes to compress folders or files on local server, but I don't found any script that compress a whole folder on a remote ftp server.
I think it was the time to ask for a help. Thanks for helping me.
|
|
|
|
|
Why post it here again! It's not accepted to cross-post, specially when you already got some answers in Q&A!!!
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Hi
I didn't get any answers since. I thought I had posted it in the wrong session; This is why I reposted it here. Sorry;
Any idea to my problem;
|
|
|
|
|
You got some! answer. If this isn't good enough than comment there!
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
The Joomla docs are very basic, so I'm asking for directions to other resources on what is involved and what I must do to create a Joomla module. The module must manage merchants and vouchers, two custom content types I presume, and members, built in I presume. I need to create/manage these, and create capture and maintenance screens for vouchers and merchants. What are the high level tasks required to do this? The coding and creation of the basic module package I can manage, but how does it all fit together etc? I'm .NET, and have only done WordPress plugins on the LAMP side.
|
|
|
|
|
Hi... I am using input box to user enter date which is the my db table. When user input date and click submit button it shows report,up to this works fine. From here I want to show 10 items per page with previous next button. How do I do?
|
|
|
|
|
Report? using which tool? Always include those details in your question.
Basically you could achieve that using options like formula. Do Google search using "Your reporting tool + paging", you'll get tons of results.
Or if you're using any direct output by HTML, use filter(s). Check these articles(not related to php)
Efficient paging using SQL script[^]
Paging GridView with ROW_NUMBER()[^]
|
|
|
|
|
Hi,
I would like to ask if anyone tried upload a photo using PHP and HTML.
I don't want to use Browse and Upload buttons. I just want the user to click on Upload which will browse then upload immediately to a dynamic folder.
are there any good free plugins available? or your recommend to code it?
Thanks,
Technology News @ www.JassimRahma.com
|
|
|
|
|
use ftp right?write(program) a can upload's website,right?use the html 5 and javascript code,right?,im a beginner and im a chinese.i have alway practise my english
|
|
|
|
|
Here is a link that may lead you to an answer you seek.
https://code.google.com/p/html5uploader/[^]
This should allow users of your site to drag and drop a file from their OS to be uploaded to your site in their browser. This will create a button to 'browse' but then they should not have to click an upload button and therefore you should not have to display an upload button.
You can have it save to a 'dynamic' directory/folder by manipulating the save directory in the PHP page that is shown on that site's page. Let's assume that that want files save into a directory named after the user but all user's folders are inside a directory called user_uploads. You will have to set it to an "id" that, obviously, would be unique to each user of your site. If users have a unique username then it could be $username or if they have a unique ID number associated with their account then it could be $user_id .
First change the name of the upload folder to what you want...as described above I am going with user_uploads:
$upload_folder = 'user_uploads';
Then you would have to do an additional change to the lines shown below to add it to the dynamic folder with the user's unique ID.
if(file_put_contents($upload_folder/$username.'/'.$headers['UP-FILENAME'], $content)) {
echo 'done';
}
For safety's sake I would either create a new directory named with a registering members unique ID upon creation of a new account or at least right before the second code shown to make sure that they actually have an existing directory to download into. Although it might be better to go with the second option here as you may have a lot of members who do not want to upload anything and therefore you could end up with a whole lot of empty directories sitting in that parent directory. Creating the directory (with appropriate permissions to store and show images) right before the upload process could ensure that only those users/members that actually want to upload something will have a folder.
You can download the 3 files plus the .js file from that link above. However, the link to demo this in action appears to be broken. But it's pretty simple and straightforward so it shouldn't take too much work to change a couple variables, upload to your server and test it yourself.
If you have a problem with this then just try searching the web for PHP HTML5 uploading for other possible options.
Many people are working with HTML5, PHP and JQuery to create such things. Just be aware that such things can be dependent upon a user having particular version numbers of particular browsers and you should make note of it accordingly on your site.
|
|
|
|
|
Hi,
I have a two mirror sites,
http:
I am trying to use the SOAP V2 in both the sites. Its working fine in ‘http:
But in ‘http:
When I open the SOAP URL ‘http:
Not able to get what the exact error is. Pls help if possible.
|
|
|
|
|
I just had these error a few days before. The problem was with the hosts file of the server. The domain name (in your case domain) wasn't in the hosts file so it PHP wasn't able to resolve it...
You can do one these things to fix it:
1. Add new entry to hosts file
2. change url to localhost or ip
3. change url to relative
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Where do i look for the host file to make an entry into the file? I access the site folder from Plesk control panel.
|
|
|
|
|
Hi all,
I am new to magento, and know very little about the coding style. I searched a lot of forum but was unable to get a proper answer to my doubt. I have added a custom column in ‘sales_flat_order_item’ table. In cart, when a item is added, a special price is calculated for each item in the cart. I need to save this calculated price in ‘sales_flat_order_item’ table when checkout. Please check the attached image. Can anyone help me as to how can I do this?
|
|
|
|
|
Hi,
I am using this code to destroy the session after sometime but it's not working! it's always redirecting to out file? why is that?
$inactive = 100;
$session_life = time() - $_SESSION['timeout'];
if ($session_life > $inactive)
{ exit(header("Location: out")); }
$_SESSION['timeout'] = time();
Technology News @ www.JassimRahma.com
|
|
|
|
|
In your case 100 is 100 seconds (you use time() that returns the time in seconds), that is not much time and that may be the reason of frequent timeout!
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
I changed it to 10000 but still having the same problem.
Technology News @ www.JassimRahma.com
|
|
|
|
|
The reason maybe that $_SESSION['timeout'] is null at the first tie you do time() - $_SESSION['timeout']. That can lead to an unpredictable large number...You have to find a way to initialize it or ask about it before use...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
what should be the value of it?
Technology News @ www.JassimRahma.com
|
|
|
|
|
time()...But it's should be a one-time initialization...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Problem solved.
Thanks guys
Technology News @ www.JassimRahma.com
|
|
|
|
|
You're welcome!
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Guys
I have one more question of you don't mind...
The code I have mentioned will kill the session after specific time, let's say 10minutes regardless of what the user is doing.
Is it possible to have the same code but only when the website is idle (user had no activity on the website)?
Thanks,
Jassim
Technology News @ www.JassimRahma.com
|
|
|
|