Search Results

Search found 28879 results on 1156 pages for 'pretty url'.

Page 87/1156 | < Previous Page | 83 84 85 86 87 88 89 90 91 92 93 94  | Next Page >

  • Amazon access key showing in URL for Carrierwave and Fog

    - by kcurtin
    I just switched from storing my images uploaded via Carrierwave locally to using Amazon s3 via the fog gem in my Rails 3.1 app. While images are being added, when I click on an image in my application, the URL is providing my access key and a signature. Here is a sample URL (XXX replaced the string with the info): https://s3.amazonaws.com/bucketname/uploads/photo/image/2/IMG_4842.jpg?AWSAccessKeyId=XXX&Signature=XXX%3D&Expires=1332093418 This is happening in development (localhost:3000) and when I am using heroku for production. Here is my uploader: class ImageUploader < CarrierWave::Uploader::Base include CarrierWave::RMagick storage :fog def store_dir "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end process :convert => :jpg process :resize_to_limit => [640, 640] version :thumb do process :convert => :jpg process :resize_to_fill => [280, 205] end version :avatar do process :convert => :jpg process :resize_to_fill => [120, 120] end end And my config/initializers/fog.rb : CarrierWave.configure do |config| config.fog_credentials = { :provider => 'AWS', :aws_access_key_id => 'XXX', :aws_secret_access_key => 'XXX', } config.fog_directory = 'bucketname' config.fog_public = false end Anyone know how to make sure this information isn't available?

    Read the article

  • What should the standard be for ReSTful URLS?

    - by gargantaun
    Since I can't find a chuffing job, I've been reading up on ReST and creating web services. The way I've interpreted it, the future is all about creating a web service for all your data before you build the web app. Which seems like a good idea. However, there seems to be a lot of contradictory thoughts on what the best scheme is for ReSTful URLs. Some people advocate simple pretty urls http://api.myapp.com/resource/1 In addition, some people like to add the API version to the url like so http://api.myapp.com/v1/resource/1 And to make things even more confusing, some people advocate adding the content-type to get requests http://api.myapp.com/v1/resource/1.xml http://api.myapp.com/v1/resource/1.json http://api.myapp.com/v1/resource/1.txt Whereas others think the content-type should be sent in the HTTP header. Soooooooo.... That's a lot of variation, which has left me unsure of what the best URL scheme is. I personally see the merits of the most comprehensive URL that includes a version number, resource locator and content-type, but I'm new to this so I could be wrong. On the other hand, you could argue that you should do "whatever works best for you". But that doesn't really fit with the ReST mentality as far as I can tell since the aim is to have a standard. And since a lot of you people will have more experience than me with ReST, I thought I'd ask for some guidance. So, with all that in mind... What should the standard be for ReSTful URLS?

    Read the article

  • Twitter O-Auth Callback url

    - by jtymann
    I am having a problem with Twitter's oauth authentication and using a callback url. I am coding in php and using the sample code referenced by the twitter wiki, http://github.com/abraham/twitteroauth I got that code, and tried a simple test and it worked nicely. However I want to programatically specify the callback url, and the example did not support that. So I quickly modified the getRequestToken() method to take in a parameter and now it looks like this: function getRequestToken($params = array()) { $r = $this->oAuthRequest($this->requestTokenURL(), $params); $token = $this->oAuthParseResponse($r); $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']); return $token; } and my call looks like this $tok = $to->getRequestToken(array('oauth_callback' => 'http://127.0.0.1/twitter_prompt/index.php')); This is the only change I made, and the redirect works like a charm, however I am getting an error when I then try and use my newly granted access to try and make a call. I get a "Could not authenticate you" error. Also the application never actually gets added to the users authorized connections. Now I read the specs and I thought all I had to do was specify the parameter when getting the request token. Could someone a little more seasoned in oauth and twitter possibly give me a hand? Thank You

    Read the article

  • Rails form with a better URL

    - by Sam
    Wow, switching to REST is a different paradigm for sure and is mainly a headache right now. view <% form_tag (businesses_path, :method => "get") do %> <%= select_tag :business_category_id, options_for_select(@business_categories.collect {|bc| [bc.name, bc.id ]}.insert(0, ["All Containers", 0]), which_business_category(@business_category) ), { :onchange => "this.form.submit();"} %> <% end %> controller def index @business_categories = BusinessCategory.find(:all) if params[:business_category_id].to_i != 0 @business_category = BusinessCategory.find(params[:business_category_id]) @businesses = @business_category.businesses else @businesses = Business.all end respond_to do |format| format.html # index.html.erb format.xml { render :xml => @businesses } end end routes map.resources What I want to to is get a better URL than what this form is presenting which is the following: http://localhost:3000/businesses?business_category_id=1 Without REST I would have do something like http://localhost:3000/business/view/bbq bbq as permalink or I would have done http://localhost:300/business_categories/view/bbq and get the business that are associated with the category but I don't really know the best way of doing this. So the two questions are what is the best logic of finding a business by its categories using the latter form and number two how to get that in a pretty URL all through RESTful routes in Rails.

    Read the article

  • Webfaction apache + mod_wsgi + django configuration issue

    - by Dmitry Guyvoronsky
    A problem that I stumbled upon recently, and, even though I solved it, I would like to hear your opinion of what correct/simple/adopted solution would be. I'm developing website using Django + python. When I run it on local machine with "python manage.py runserver", local address is http://127.0.0.1:8000/ by default. However, on production server my app has other url, with path - like "http://server.name/myproj/" I need to generate and use permanent urls. If I'm using {% url view params %}, I'm getting paths that are relative to / , since my urls.py contains this urlpatterns = patterns('', (r'^(\d+)?$', 'myproj.myapp.views.index'), (r'^img/(.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT + '/img' }), (r'^css/(.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT + '/css' }), ) So far, I see 2 solutions: modify urls.py, include '/myproj/' in case of production run use request.build_absolute_uri() for creating link in views.py or pass some variable with 'hostname:port/path' in templates Are there prettier ways to deal with this problem? Thank you. Update: Well, the problem seems to be not in django, but in webfaction way to configure wsgi. Apache configuration for application with URL "hostname.com/myapp" contains the following line WSGIScriptAlias / /home/dreamiurg/webapps/pinfont/myproject.wsgi So, SCRIPT_NAME is empty, and the only solution I see is to get to mod_python or serve my application from root. Any ideas?

    Read the article

  • Trouble with Router::url() when using named parameters

    - by sibidiba
    I'm generating plain simple links with CakePHP's HtmlHelper the following way: $html->link("Newest", array( 'controller' => 'posts', 'action' => 'listView', 'page'=> 1, 'sort'=>'Question.created', 'direction'=>'desc', )); Having the following route rule: Router::connect('/foobar/*',array( 'controller' => 'posts', 'action' => 'listView' )); The link is nicely generated as /foobar/page:1/sort:Question.created/direction:desc. Just as I want, it uses my URL prefix instead of controller/action names. However, for some links I must add named parameters like this: $html->link("Newest", array( 'controller' => 'posts', 'action' => 'listView', 'page'=> 1, 'sort'=>'Question.created', 'direction'=>'desc', 'namedParameter' => 'namedParameterValue' )); The link in this case points to /posts/listView/page:1/sort:Question.created/direction:desc/namedParameter:namedParameterValue. But I do not want to have contoller/action names in my URL-s, why is Cake ignoring in this case my routers configuration?

    Read the article

  • relative url in wcf service binding

    - by Jeremy
    I have a silverlight control which has a reference to a silverlight enabled wcf service. When I add a reference to the service in my silverlight control, it adds the following to my clientconfig file: <configuration> <system.serviceModel> <bindings> <basicHttpBinding> <binding name="BasicHttpBinding_DataAccess" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"> <security mode="None" /> </binding> </basicHttpBinding> </bindings> <client> <endpoint address="http://localhost:3097/MyApp/DataAccess.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_DataAccess" contract="svcMyService.DataAccess" name="BasicHttpBinding_DataAccess" /> </client> </system.serviceModel> </configuration> How do I specify a relative url in the endpoint address instead of the absolute url? I want it to work no matter where I deploy the web app to without having to edit the clientconfig file, because the silverlight component and the web app will always be deployed together. I thought I'd be able to specify just "DataAccess.svc" but it doesn't seem to like that.

    Read the article

  • routing mvc on the web

    - by generic_noob
    Hi, I was wondering if anyone could possibly provide me some advice on how i could improve the routing (and/or architecture) to each 'section' of my application. (I'm writing in PHP5, and trying to use strict MVC) Basically, I have a generic index page for the app, and that will spew out boilerplate stuff like jquery and the css etc. and it also generates the main navidation for the entire site, but i'm unsure about the best approach to connect the 'main menu' items(hyperlinks) with their associated controllers. Up until now I have been appending strings into the url and using a 'switch' statement to branch to the correct controller(and view) by extracting the strings back out of '$GET[]' to let it execute the code for the corrosponding action. for instance if i had a basic crud system for customer data, the url to edit a customers details would look like 'www.example.com/index.php?page=customer&action=edit&id=4'. I'm worried that there is a security concern by doing it this way, and i'm not sure of an alternative to branch the main 'index.php' file to the correct controller for each action once the user has clicked the link. Would it be better to use mod_rewrite to disguise the controllers names? or to create a similar system to the ASP MVC framework, where there is a seperate routing system where each url is filtered to get the associated controller? Cheers!

    Read the article

  • ASP.NET MVC URL Routing problem

    - by Sadegh
    hi, i have defined a route as below: context.MapRoute("SearchEngineWebSearch", "search/web/{query}/{index}/{size}", new { controller = "search", action = "web", query = "", index = 0, size = 5 }); and action method to handle request match with that: public System.Web.Mvc.ActionResult Web(string query = "", int index = 0, int size = 5) { if (string.IsNullOrEmpty(query)) return RedirectToRoute("SearchEngineBasicSearch"); var search = new Search(); var results = search.PerformSearch(query, index, size); ViewData["Query"] = query; if (results != null && results.Count() > 0) { ViewData["Results"]= results; return View("Web"); } else return View("Not-Found"); } and form to sent parameter to action method: <% using (Html.BeginForm("Web", "Search", FormMethod.Post)) { %> <input name="query" type="text" value="<%: ViewData["Query"]%>" class="search-field" /> <input type="submit" value="Search" class="search-button" /> <input type="hidden" name="index" value="2" /> <input type="hidden" name="size" value="2" /> <%} %> now after click on submit and sending value to action method all route values updated but url values still is equals to first time of sending parameter. for example if i sent for first time request such as http://localhost/search/web/google and for next time http://localhost/search/web/yahoo, query parameter which passed to action method is yahoo but url after postback is http://localhost/search/web/google still! can anybody help me plz? ;)

    Read the article

  • How can i fetch the large image from url

    - by Kutbi
    i used below code to fetch the image from url.but its not working for large image.. i missing something to add for that type of image to fetch. imgView = (ImageView)findViewById(R.id.ImageView01); imgView.setImageBitmap(loadBitmap("http://www.360technosoft.com/mx4.jpg")); //imgView.setImageBitmap(loadBitmap("http://sugardaddydiaries.com/wp-content/uploads/2010/12/how_do_i_get_sugar_daddy.jpg")); //setImageDrawable("http://sugardaddydiaries.com/wp-content/uploads/2010/12/holding-money-copy.jpg"); //Drawable drawable = LoadImageFromWebOperations("http://www.androidpeople.com/wp-content/uploads/2010/03/android.png"); //imgView.setImageDrawable(drawable); /* try { ImageView i = (ImageView)findViewById(R.id.ImageView01); Bitmap bitmap = BitmapFactory.decodeStream((InputStream)new URL("http://sugardaddydiaries.com/wp-content/uploads/2010/12/holding-money-copy.jpg").getContent()); i.setImageBitmap(bitmap); } catch (MalformedURLException e) { System.out.println("hello"); } catch (IOException e) { System.out.println("hello"); }*/ } protected Drawable ImageOperations(Context context, String string, String string2) { // TODO Auto-generated method stub try { InputStream is = (InputStream) this.fetch(string); Drawable d = Drawable.createFromStream(is, "src"); return d; } catch (MalformedURLException e) { e.printStackTrace(); return null; } catch (IOException e) { e.printStackTrace(); return null; } }

    Read the article

  • How to handle building and parsing HTTP URL's / URI's / paths in Perl

    - by Robert S. Barnes
    I have a wget like script which downloads a page and then retrieves all the files linked in img tags on that page. Given the URL of the original page and the the link extracted from the img tag in that page I need to build the URL for the image file I want to retrieve. Currently I use a function I wrote: sub build_url { my ( $base, $path ) = @_; # if the path is absolute just prepend the domain to it if ($path =~ /^\//) { ($base) = $base =~ /^(?:http:\/\/)?(\w+(?:\.\w+)+)/; return "$base$path"; } my @base = split '/', $base; my @path = split '/', $path; # remove a trailing filename pop @base if $base =~ /[[:alnum:]]+\/[\w\d]+\.[\w]+$/; # check for relative paths my $relcount = $path =~ /(\.\.\/)/g; while ( $relcount-- ) { pop @base; shift @path; } return join '/', @base, @path; } The thing is, I'm surely not the first person solving this problem, and in fact it's such a general problem that I assume there must be some better, more standard way of dealing with it, using either a core module or something from CPAN - although via a core module is preferable. I was thinking about File::Spec but wasn't sure if it has all the functionality I would need.

    Read the article

  • Apache friendly urls

    - by HaukurHaf
    Hi everyone. I've got a small CMS system written in PHP and running on Apache. The format of the URLs this CMS system uses/generates is: /display.php?PageID=xxx where xxx is just some integer number. As you can see, those URLs are not very friendly, neither for users nor search engines. I believe that using mod_rewrite (or something like that) and .htaccess files I should be able to configure Apache for URL-rewriting. I have searched for information about this before but I did not find any easy method to do this, it always involved messing with regular expressions, which I'm not very familiar with. Since the website in question is really simple and small, just 5-10 different pages, I would really like to be able to just hard-code the configuration, without any special rules or regexps. I'd just like to map a friendly URL to an actual URL, perhaps like this: /about = /display.php?PageID=44 /products = /display.php?PageID=34 etc. Is it possible to configure the mod_rewrite plugin in a basic way like this? Could someone explain the easiest method to do this? Explain it to me as if I was a child :-) Thanks in advance!

    Read the article

  • Re-authentication required for registered-path links (to ASP.NET site) coming to IE from PowerPoint

    - by Daniel Halsey
    We're using URL routing based on Phil Haack's example, with config modifications based on MSDN Library article #CC668202, to provide "shareable" links for a ASP.NET forms site, and have run into a strange issue: For users attempting to open links from PowerPoint presentations, and who have IE set as their default browser, using one of these links forces (forms-based) re-authentication, even in the same browser instance with a live session. Info: We know the session is still alive. (Page returns information for the currently logged-in user; confirmed via debug watches) This doesn't happen with other browsers (FF, Chrome) or with other programs (Notepad++) as the URL source. We do not have a default path set, as this caused issues with root path handling at initial login. This primarily happens with PowerPoint, but will also happen in Word and OCS. On some machines, even after changing the default browser, Office apps will continue to use IE for these links, forcing this error. (A potential registry fix for this failed, but even if it had worked, we can't control default browser choice for our users.) We can't figure out if this is an Office oddity or is being caused by our decision to use app-level URL routing (rather than IIS rewriting). Has anyone else encountered this and found a solution?

    Read the article

  • ASP.NET MVC URL/Routing question

    - by Hobbes
    Hello! I am an MVC newbie. I'm trying to get my URLs to look like this: /Corporate/Users/Edit/1 /Corporate/Stores/Edit/17 /Corporate/Contacts/Edit/17 /Store/Contacts/Create /Store/Products/Edit/29 Pretty much like plain-vanilla urls, except with a user type at the front. I'm running into a lot of problems with duplicate controller names, etc. Is there a simple way to do this? I looked briefly at Areas, but this seemed way to complicated.

    Read the article

  • JarEntry.getSize() is returning -1 when the jar files is opened as InputStream from URL

    - by Reshma Donthireddy
    I am trying to read file from the JarInputStream and the size of file is returning -1. I am accessing Jar file from the URL as a inputStream. URLConnection con = url.openConnection(); JarInputStream jis = new JarInputStream(con.getInputStream()); JarEntry je = null; while ((je = jis.getNextJarEntry()) != null) { htSizes.put(je.getName(), new Integer((int) je.getSize())); if (je.isDirectory()) { continue; } int size = (int) je.getSize(); // -1 means unknown size. if (size == -1) { size = ((Integer) htSizes.get(je.getName())).intValue(); } byte[] b = new byte[(int) size]; int rb = 0; int chunk = 0; while (((int) size - rb) > 0) { chunk = jis.read(b, rb, (int) size - rb); if (chunk == -1) { break; } rb += chunk; } // add to internal resource hashtable htJarContents.put(je.getName(), baos.toByteArray()); }

    Read the article

  • Passing HTML form data in the URL on local machine (file://)

    - by atzz
    Hi, I'm building a small HTML/JS application for primary use on local machine (i.e. everything is accessed via file:// protocol, though maybe in the future it will be hosted on a server within intranet). I'm trying to make a form with method="get" and action="target.html", in the hope that the browser will put form data in the URL (like, file://<path>/target.html?param1=aaa&param2=bbb). However, it's not happening (target.html opens fine, but no parameters is passed). What am I doing wrong? Is it possible to use forms over file:// at all? I can always build the url manually (via JS), but being lazy I'd prefer the browser do it for me. ;) Here is my sample form: <form name='config' action="test_form.html" method="get" enctype="application/x-www-form-urlencoded"> <input type="text" name="param1"> <input type="text" name="param2"> <input type="submit" value="Go"> </form>

    Read the article

  • Polling a web URL until event

    - by Jaxo
    I'm really sorry about the crappy title - if anybody has a better way of wording it, please edit it! I basically need to have a C# application run a function if the output of a URL is a certain value. For example, if the website says blue the background colour will be blue, red to make it red, etc. The problem is I don't want to spam my webserver with checks. The 4 bytes it downloads each time is negligible, but if I were to deploy this type of system on multiple computers, it would get slower and slower and the bandwidth would add up quickly. So my question is: How can my desktop application run a piece of code only when a web URL has a different output without checking each time? I can't use sockets, and any sort of LAN protocol won't end up working. My reasoning behind this potentially nefarious code is to be able to mute computers by updating a file on the website (as you may have seen in my previous question today, sorry!). I'd like it to be rather quick, and not have the refresh time minutes apart, a few seconds at the most would be ideal. How can I accomplish this? The website's code is easy, but getting the C# application to check when it changes is the part I'm stuck on. Nothing shows up on the website other than the command. Thanks!

    Read the article

  • Prevent hash navigation url

    - by Koningh
    I have the following problem: I'm using a slider (coda) to let people navigate trough some 'pages'. The slider uses hash links to navigate to the next page/slide. If a user is at page one (#page1), there is a link which will lead the user to page 2 (#page2) and so on. At the top of the slider the numbers of the pages appear as a link, but only when the page is visited. So if there are six pages and the user navigates from the first to the second and then the third one, there are only three links at the top of the slider (to page one, two and three). The problem is that a user can navigate to page five (or any page actually) without first visiting the pages previous to page five by just using the hash URL and typing the whole link in their address bar. For example if I would type www.mydomain.com/slider/index.php#page5 the slider automatically navigates to the fifth slide/page of the slider and thereby skipping the first four. I want to allow users to navigate to #page5 only if they have visited the first four (So by clicking trough the slides). This means that if they would go to #page5 directly by typing the URL in the address bar, I would like them to be send to the first page (#page1). Does anyone have any idea on solving this?

    Read the article

  • Get Url Parameters In Django

    - by picomon
    I want to get current transaction id in url. it should be like this www.example.com/final_result/53432e1dd34b3 . I wrote the below codes, but after successful payment, I'm redirected to Page 404. (www.example.com/final_result//) Views.py @csrf_exempt def pay_notif(request, v_transaction_id): if request.method=='POST': v_transaction_id=request.POST.get('transaction_id') endpoint='https://testpay.com/?v_transaction_id={0}&type=json' req=endpoint.format(v_transaction_id) last_result=urlopen(req).read() if 'Approved' in last_result: session=Pay.objects.filter(session=request.session.session_key).latest('id') else: return HttpResponse(status=204) return render_to_response('final.html',{'session':session},context_instance=RequestContext(request)) Urls.py url(r'^final_result/(?P<v_transaction_id>[-A-Za-z0-9_]+)/$', 'digiapp.views.pay_notif', name="pay_notif"), Template: <input type='hidden' name='v_merchant_id' value='{{newpayy.v_merchant_id}}' /> <input type='hidden' name='item_1' value='{{ newpayy.esell.up_name }}' /> <input type='hidden' name='description_1' value='{{ newpayy.esell.up_description }}' /> <input type='hidden' name='price_1' value='{{ newpayy.esell.up_price }}' /> #page to be redirected to after successful payment <input type='hidden' name='success_url' value='http://127.0.0.1:8000/final_result/{{newpayy.v_transaction_id}}/' /> How can I go about this?

    Read the article

  • Mapping a URL to a service inside a class library

    - by johnk82swe
    I'm developing a small content management solution than can be used in any ASP.NET 3.5 website. The website references some dll's and then lets the aspx's inherit my page baseclass. Some configuration in web.config is also needed, but thats it. Now I'm building a standalone Silverlight editor for the CMS. My idea is that it should communicate with the server using web services. But the question is how to make this service available to the editor? I don't want the website developers having to bother with it. If I used a REST API rather than SOAP I could just create an HttpHandler in my class library and let the website developers add a handler to it in web.config with the path "editor" and then the editor could communicate with that handler on mywebsite.com/editor. Is there any way to achieve the same with a asmx or wcf service? The important thing is that the website developers never have to set up any asmx files or anything. They should only have to specify a url and map that url to a service inside my class library. Thanks in advance!

    Read the article

  • Rails from with better url

    - by Sam
    wow, switching to rest is a different paradigm for sure and is mainly a headache right now. view <% form_tag (businesses_path, :method => "get") do %> <%= select_tag :business_category_id, options_for_select(@business_categories.collect {|bc| [bc.name, bc.id ]}.insert(0, ["All Containers", 0]), which_business_category(@business_category) ), { :onchange => "this.form.submit();"} %> <% end %> controller def index @business_categories = BusinessCategory.find(:all) if params[:business_category_id].to_i != 0 @business_category = BusinessCategory.find(params[:business_category_id]) @businesses = @business_category.businesses else @businesses = Business.all end respond_to do |format| format.html # index.html.erb format.xml { render :xml => @businesses } end end routes map.resources What I want to to is get a better url than what this form is presenting which is the following: http://localhost:3000/businesses?business_category_id=1 Without rest I would have do something like http://localhost:3000/business/view/bbq bbq as permalink or I would have done http://localhost:300/business_categories/view/bbq and get the business that are associated with the category but I don't really know the best way of doing this. So the two questions are what is the best logic of finding a business by its categories using the latter form and number two how to get that in a pretty url all through restful routes in rails.

    Read the article

  • Using Javascript to get URL Vars, not working when multiple values present in QueryString

    - by bateman_ap
    Hi, I am using a Javascript function to get the values of a URL to pass to jQuery using the function below: function getUrlVars() { var vars = [], hash; var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); for(var i = 0; i < hashes.length; i++) { hash = hashes[i].split('='); vars.push(hash[0]); vars[hash[0]] = hash[1]; } return vars; } And then setting the value like this: var type = getUrlVars()["type"] This all works perfectly, however I have just come into a situation where I need to get multiple values, one of my form elements are checkboxes where multiple values can be checked, so my URL will look something like this: http://www.domain.com/test.php?type=1&cuisine[]=23&cuisine[]=43&name=test If I alert out the cuisine value using the function above I only ever get the final value: alert (getUrlVars()["cuisine[]"]); Would alert "43". What I would like it to be is a comma delimited string of all "cuisine" values. ie in the above example "23,43" Any help very welcome! In case any solution requires it I am using PHP 5.3 and Jquery 1.4

    Read the article

  • Wordpress Widget - Adding URL to title

    - by Nick Canarelli
    I can't seem to figure out how to wrap the title of the widget in an tag. For example, I am trying to get it so that when you type the url in a text field, it is then placed in the tag so that it is a hyperlink on the website... class Example_Widget extends WP_Widget { /** * Widget setup. */ function Example_Widget() { /* Widget settings. */ $widget_ops = array( 'classname' => 'example', 'description' => __('A widget that displays company announcements.', 'example') ); /* Widget control settings. */ $control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'example-widget' ); /* Create the widget. */ $this->WP_Widget( 'example-widget', __('Announcement Widget', 'example'), $widget_ops, $control_ops ); } /** * How to display the widget on the screen. */ function widget( $args, $instance ) { extract( $args ); /* Our variables from the widget settings. */ $title = apply_filters('widget_title', $instance['title'] ); $excerpt = $instance['excerpt']; $url = $instance['url']; /* Before widget (defined by themes). */ echo $before_widget; /* Display the widget title if one was input (before and after defined by themes). */ if ( $title ) echo $before_title . $title . $after_title; /* Display name from widget settings if one was input. */ if ( $excerpt ) printf( '<p style="font-family: arial; font-size: 12px; line-height: 16px;">' . __('%1$s.', 'example') . '</p>', $excerpt ); /* After widget (defined by themes). */ echo $after_widget; } /** * Update the widget settings. */ function update( $new_instance, $old_instance ) { $instance = $old_instance; /* Strip tags for title and name to remove HTML (important for text inputs). */ $instance['title'] = strip_tags( $new_instance['title'] ); $instance['excerpt'] = strip_tags( $new_instance['excerpt'] ); return $instance; } /** * Displays the widget settings controls on the widget panel. * Make use of the get_field_id() and get_field_name() function * when creating your form elements. This handles the confusing stuff. */ function form( $instance ) { /* Set up some default widget settings. */ $defaults = array( 'title' => __('Title Goes Here', 'example'), 'excerpt' => __('Excerpt goes here.'), ); $instance = wp_parse_args( (array) $instance, $defaults ); ?> <!-- Widget Title: Text Input --> <p> <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'hybrid'); ?></label> <input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" style="width:100%;" /> </p> <!-- Your Name: Text Input --> <p> <label for="<?php echo $this->get_field_id( 'excerpt' ); ?>"><?php _e('Excerpt:', 'example'); ?></label> <input id="<?php echo $this->get_field_id( 'excerpt' ); ?>" name="<?php echo $this->get_field_name( 'excerpt' ); ?>" value="<?php echo $instance['excerpt']; ?>" style="width:100%;" /> </p> <?php } } ?> And here is the functions file code register_sidebar(array( 'name' => __( 'Announcements' ), 'description' => __( 'Display company announcements here.' ), 'before_widget' => '', 'after_widget' => '<hr style="margin-top: 4px; color: #f00; background-color: #585040; height: 1px; border: none; margin-bottom: 2px;"/>', 'before_title' => '<h2 style="font-size: 12px;">', 'after_title' => '</h2>' ));

    Read the article

< Previous Page | 83 84 85 86 87 88 89 90 91 92 93 94  | Next Page >