Daily Archives

Articles indexed Thursday October 4 2012

Page 11/16 | < Previous Page | 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Circle-Rectangle collision in a tile map game

    - by furiousd
    I am making a 2D tile map based putt-putt game. I have collision detection working between the ball and the walls of the map, although when the ball collides at the meeting point between 2 tiles I offset it by 0.5 so that it doesn't get stuck in the wall. This aint a huge issue though. if(y % 20 == 0) { y+=0.5; } if(x % 20 == 0) { x+=0.5; } Collisions work as follows Find the closest point between each tile and the center of the ball If distance(ball_x, ball_y, close_x, close_y) <= ball_radius and the closest point belongs to a solid object, collision has occured Invert X/Y speed according to side of object collided with The next thing I tried to do was implement floating blocks in the middle of the map for the ball to bounce off of. When a ball collides with a corner of the block, it gets stuck in it. So I changed my determineRebound() function to treat corners as if they were circles. Here's that functon: `i and j are indexes of the solid object in the 2d map array. x & y are centre point of ball.` void determineRebound(int _i, int _j) { if(y > _i*tile_w && y < _i*tile_w + tile_w) { //Not a corner xs*=-1; } else if(x > _j*tile_w && x < _j*tile_w + tile_w) { //Not a corner ys*=-1; } else { //Corner float nx = x - close_x; float ny = y - close_y; float len = sqrt(nx * nx + ny * ny); nx /= len; ny /= len; float projection = xs * nx + ys * ny; xs -= 2 * projection * nx; ys -= 2 * projection * ny; } } This is where things have gotten messy. Collisions with 'floating' corners work fine, but now when the ball collides near the meeting point of 2 tiles, it detects a corner collision and does not rebound as expected. I'm a bit in over my head at this point. I guess I'm wondering if I'm going about making this sort of game in the right way. Is a 2d tile map the way to go? If so, is there a problem with my collision logic and where am I going wrong? Any advice/feedback would be great.

    Read the article

  • Good practices while working with multiple game engines, porting a game to a new engine

    - by Mahbubur R Aaman
    I have to work with multiple game engines, like Cocos2d Unity3d Galaxy While working with multiple game engines, what practices should i follow? EDIT: Is there any guideline to follow, that would be better as while any one working with multiple game engines? EDIT: While a game made by Cocos2d and done well at AppStore, then our target it to port to other platforms, then we utilize Unity3D. Here what should we do?

    Read the article

  • Getting velocity in only one plane (X) in Kismet (UDK)

    - by anna1987
    I'm trying to make a character in 2.5 platformer (in UDK) to "climb" a giant tree trunk by walking on a spiral staircase enveloped around the tree. When character goes right the tree rotates thru matinee sequence so it seems that the character is moving while in reality it is the tree that moves. I connected the matinee sequence playrate to the velocity of the character and its all good as long the character just moves left or right. When it jumps though, the velocity still affects the playrate - it should not as character moves up/down, not right/left. How do I set it up in Kismet so I get a float variable with velocity only in the X plane (horizontal)?

    Read the article

  • C++ Directx 11 D3DXVec3Unproject

    - by Miguel P
    Hello dear people from the underworld called the internet. So guys, Im having a small issue with D3DXVec3Unproject, because I'm currently using Directx 11 and not 10, and the requirements for this function is: D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3D10_VIEWPORT *pViewport, CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld As you may have noticed, it requires a D3D10_VIEWPORT, and I'm using a Directx 11 viewport, D3D11_VIEWPORT. So do you have any ideas how i can use D3DXVec3Unproject with Directx 11? Thank You

    Read the article

  • How relevant is PHP today for browser games?

    - by Bitgarden
    I was the lead developer of 2 moderately successful browser games quite a few years back, and plan on working on a new game soon. At the time, I wrote them in pure PHP (no template engine or anything of the sort). I'd like to start working on a new game, but have been out of the web development world for a while. Reading around, I hear a lot of good about Rails, Django, Node.js, etc., with which I have no experience (although I know my way around Python, Javascript, and the others quite well). So my question is the following- if I were to go in my old ways and go with PHP again, would I be making things hard for myself? Would picking something more "trendy" have a real impact on my development? In addition, does anyone have any pointers relating to specifically developing browser games with these more modern tools?

    Read the article

  • Most efficient 3d depth sorting for isometric 3d in AS3?

    - by AttackingHobo
    I am not using the built in 3d MovieClips, and I am storing the 3d location my way. I have read a few different articles on sorting depths, but most of them seem in efficient. I had a really efficient way to do it in AS2, but it was really hacky, and I am guessing there are more efficient ways that do not rely on possibly unreliable hacks. What is the most efficient way to sort display depths using AS3 with Z depths I already have?

    Read the article

  • Facebook RunWithFriend redirects to homepage

    - by Clynamen
    I'm following the Canvas app Example of Facebook, but it seems that I'm unable to login succesfully, thus I'm unable to use the example app because I'm always redirected to the main page. I think I set all the parameters correctly, except for the OAuth Migration that should be enabled. There is no such option in Facebook developer panel. This is a screen of the main page as it appears to me after the login: I have the same problem explained here: Canvas demo (runwithfriends) always redirects to main page under my own GAE with the exception that even the application on facebook GAE redirects me to the main page even if I successfully log in. Did anyone experienced a similar problem?

    Read the article

  • ordering an acts_as_tree relationship

    - by timpone
    I have a Category class that is defined like this: class Catergoy < ActiveRecord::Base acts_as_tree :parent_id I'd like the ordering to be by the position value which is a float such that: category-1 category-2, parent_id=1, position=0.5 category-3, parent_id=2, category-4, parent_id=1, position=1 How would I specify this? I tried acts_as_tree :parent_id :order => :position acts_as_tree :parent_id, :order => :position but these are not working. Any ideas how to specify this relationship? Or if I'm missing something else? thx in advance

    Read the article

  • C# Replace two specific commas in a string with many commas

    - by Hal
    I am trying to change the date format in each line from commas to hyphens. The index of the comma separating the month and day day and year varies. lines_in_List[i] = lines_in_List[i].Insert(0, cnt + ","); // Insert Draw # in 1st column string one_line = lines_in_List[i]; // 0,5,1,2012,1,10,19,16,6,36,,, // 1,11,5,2012,49,35,23,37,38,28,,, // 2,12,10,2012,8,52,53,54,47,15,,, // ^-^--^ replace the ',' with a '-'. StringBuilder changed = new StringBuilder(one_line); changed[3] = '-'; changed[5] = '-'; changed[3] = '-'; lines_in_List[i] = changed.ToString(); }

    Read the article

  • Comparing an id to id of different tables rows mysql

    - by jett
    So I am trying to retrieve all interests from someone, and be able to list them. This works with the following query. SELECT *,( SELECT GROUP_CONCAT(interest_id SEPARATOR ",") FROM people_interests WHERE person_id = people.id ) AS interests FROM people WHERE id IN ( SELECT person_id FROM people_interests WHERE interest_id = '.$site->db->clean($_POST['showinterest_id']).' ) ORDER BY lastname, firstname In this one which I am having trouble with, I want to select only those who happen to have their id in the table named volleyballplayers. The table just has an id, person_id, team_id, and date fields. SELECT *,( SELECT GROUP_CONCAT(interest_id SEPARATOR ",") FROM people_interests WHERE person_id = people.id ) AS interests FROM people WHERE id IN ( SELECT person_id FROM people_interests WHERE volleyballplayers.person_id = person_id ) ORDER BY lastname, firstname I just want to make sure that only the people who are in the volleyballplayers table show up, but I am getting an error saying that Unknown column 'volleyballplayers.person_id' in 'where clause' although I am quite sure of the name of table and I know the column is named person_id.

    Read the article

  • Custom listview entry works in JB not in Gingerbread

    - by Andy
    I have a ListFragment with a custom ArrayAdapter where I am overiding getView() to provide a custom View for the list item. private class DirListAdaptor extends ArrayAdapter<DirItem> { @Override public View getView(int position, View convertView, ViewGroup parent) { View aView = convertView; if (aView == null) { LayoutInflater vi = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); // TODO: can we not access textViewResourceId? aView = vi.inflate(R.layout.dir_list_entry, parent, false); } etc... Here is the dir_list_entry.xml: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="?android:attr/listPreferredItemHeight" android:paddingLeft="?android:attr/listPreferredItemPaddingLeft" android:paddingRight="?android:attr/listPreferredItemPaddingRight"> <ImageView android:id="@+id/dir_list_icon" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_alignParentTop="true" android:layout_alignParentBottom="true" android:layout_marginRight="6dp" android:src="@drawable/ic_launcher" /> <TextView android:id="@+id/dir_list_details" android:textAppearance="?android:attr/textAppearanceListItem" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_toRightOf="@id/dir_list_icon" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:singleLine="true" android:ellipsize="marquee" android:textSize="12sp" android:text="Details" /> <TextView android:id="@+id/dir_list_filename" android:textAppearance="?android:attr/textAppearanceListItem" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_toRightOf="@id/dir_list_icon" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:layout_above="@id/dir_list_details" android:layout_alignWithParentIfMissing="true" android:gravity="center_vertical" android:textSize="14sp" android:text="Filename"/> </RelativeLayout> The bizarre thing is this works fine on Android 4.1 emulator, but I get the following error on Android 2.3: 10-01 15:07:59.594: ERROR/AndroidRuntime(1003): FATAL EXCEPTION: main android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout at android.view.LayoutInflater.createView(LayoutInflater.java:518) at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568) at android.view.LayoutInflater.inflate(LayoutInflater.java:386) at android.view.LayoutInflater.inflate(LayoutInflater.java:320) at com.eveps.evepsdroid.ui.PhotoBrowserListFragment$DirListAdaptor.getView(PhotoBrowserListFragment.java:104) at android.widget.AbsListView.obtainView(AbsListView.java:1430) at android.widget.ListView.makeAndAddView(ListView.java:1745) at android.widget.ListView.fillDown(ListView.java:670) at android.widget.ListView.fillFromTop(ListView.java:727) at android.widget.ListView.layoutChildren(ListView.java:1598) at android.widget.AbsListView.onLayout(AbsListView.java:1260) at android.view.View.layout(View.java:7175) at android.widget.FrameLayout.onLayout(FrameLayout.java:338) at android.view.View.layout(View.java:7175) at android.widget.FrameLayout.onLayout(FrameLayout.java:338) at android.view.View.layout(View.java:7175) at android.widget.FrameLayout.onLayout(FrameLayout.java:338) at android.view.View.layout(View.java:7175) at android.widget.FrameLayout.onLayout(FrameLayout.java:338) at android.view.View.layout(View.java:7175) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254) at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1243) at android.widget.LinearLayout.onLayout(LinearLayout.java:1049) at android.view.View.layout(View.java:7175) at android.widget.FrameLayout.onLayout(FrameLayout.java:338) at android.view.View.layout(View.java:7175) at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1254) at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1130) at android.widget.LinearLayout.onLayout(LinearLayout.java:1047) at android.view.View.layout(View.java:7175) at android.widget.FrameLayout.onLayout(FrameLayout.java:338) at android.view.View.layout(View.java:7175) at android.view.ViewRoot.performTraversals(ViewRoot.java:1140) at android.view.ViewRoot.handleMessage(ViewRoot.java:1859) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:123) at android.app.ActivityThread.main(ActivityThread.java:3683) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:507) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.constructNative(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:415) at android.view.LayoutInflater.createView(LayoutInflater.java:505) ... 42 more Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x2 at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:463) at android.view.View.<init>(View.java:1957) at android.view.View.<init>(View.java:1899) at android.view.ViewGroup.<init>(ViewGroup.java:286) at android.widget.RelativeLayout.<init>(RelativeLayout.java:173) ... 45 more I'm using the Android Support library for fragment support obviously. Seems to be a problem inflating the custom list view entry, something to do with a dimension - but why does it work on JellyBean? Has something changed in this area?

    Read the article

  • iOS app won't compile on device but works fine in simulator

    - by Jhorra
    I'm assuming this has something to do with linking, but I've removed RestKit and re-added it. I made sure all my connections and linking was in place. If I set XCode to use the simulator it runs fine, but as soon as I set it to run on any device it won't even build. The only other thing of note is this didn't start happening till I upgraded to XCode 4.5. Below are the errors it gives me ld: warning: ignoring file /Users/luke/Library/Developer/Xcode/DerivedData/ehrx-btsujlxuhtytahfaikwjeqfjybtt/Build/Products/Debug-iphoneos/libRestKit.a, file was built for archive which is not the architecture being linked (armv7s): /Users/luke/Library/Developer/Xcode/DerivedData/ehrx-btsujlxuhtytahfaikwjeqfjybtt/Build/Products/Debug-iphoneos/libRestKit.a Undefined symbols for architecture armv7s: "_OBJC_CLASS_$_RKClient", referenced from: objc-class-ref in ehrxAppDelegate.o objc-class-ref in ehrxLoginView.o objc-class-ref in ehrxInboxView.o objc-class-ref in ehrxCMView.o objc-class-ref in ehrxEncounterDemoView.o objc-class-ref in ehrxEncounterDiagListView.o objc-class-ref in ehrxEncounterChargeView.o ... ld: symbol(s) not found for architecture armv7s clang: error: linker command failed with exit code 1 (use -v to see invocation)

    Read the article

  • If either one of both equals

    - by user1620028
    I have start and end dates which are stored in a database in this format: start date= 20121004 //4th October 2012 end date= 20121004 //16th November 2012 so I can use date format: $date = date("Ymd"); // returns: 20121004 to determine when to display and not display to repopulate my update input boxes I use: $start=(str_split($stdate,4));// START DATE: splits stored date into 2x4 ie: 20121209 = 2012 1209 $syr = $start[0];// re first half ie: 2012 which is the year $start2 = $start[1];//re second half ie: 1209 $start3=(str_split($start2,2));// splits second half date into 2x2 ie: 1209 = 12 09 $smth = $start3[0]; // first half = month ie: 12 $sday = $start3[1]; // second half = day ie: 09 $expiry=(str_split($exdate,4)); ///SAME AGAIN FOR EXPIRY DATE ... $xyr = $expiry[0]; $expiry2 = $expiry[1]; $expiry3=(str_split($expiry2,2)); $xmth = $expiry3[0]; $xday = $expiry3[1]; which works fine but I need to repopulate the input boxes for the month showing the date in the database like this <option value="01">January</option`> using if ($smth==01):$month='January'; endif; if ($xmth==01):$month='January'; endif; // if the start and/or expiry month number = 01 display $month as January if ($smth==02):$smonth='February'; endif; if ($xmth==02):$smonth='February'; endif; if ($smth==03):$month='March'; endif; <select name="stmonth" class="input"> <option value="<?=$smth?>"><?=$month?></option> ... </select> is there an easier way to display IF EITHER ONE EQUALS rather than having to write the same line twice once for each $smth AND $xmth ? re: if ($smth **and or** $xmth ==01):$month='January'; endif;

    Read the article

  • Python : How to add month to December 2012 and get January 2013?

    - by daydreamer
    >>> start_date = date(1983, 11, 23) >>> start_date.replace(month=start_date.month+1) datetime.date(1983, 12, 23) This works until the month is <=11, as soon as I do >>> start_date = date(1983, 12, 23) >>> start_date.replace(month=start_date.month+1) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: month must be in 1..12 How can I keep adding months which increments the year when new month is added to December?

    Read the article

  • Iframe not displaying content

    - by a coder
    This snippet was gathered from a random youtube video: <iframe class="youtube-player" src="http://www.youtube.com/embed/http://www.youtube.com/v/gnrvYsZWR1c?rel=0" title="YouTube video player" type="text/html" frameborder="0" height="390" width="480"></iframe> Again, a little easier to read: <iframe class="youtube-player" src="http://www.youtube.com/embed/http://www.youtube.com/v/gnrvYsZWR1c?rel=0" title="YouTube video player" type="text/html" frameborder="0" height="390" width="480" ></iframe> It is not displaying the embedded youtube in Firefox 15.0.1 on Windows or Linux. Is there a problem with how this snippet is constructed, or is Firefox simply not displaying iframe content?

    Read the article

  • Type casting int into double C++

    - by user1705380
    I am new to programming and this might be an obvious question, though i cannot for life of me figure out why my program is not returning as a double. I am suppose to write a stocks program that takes in shares of stock, whole dollar portion of price and the fraction portion. And the fraction portion is to be inputted as two int values, and include a function definition with 3 int values.The function returns the price as a double. #include <iostream> using namespace std; int price(int, int, int); int main() { int dollars, numerator, denominator, price1, shares; char ans; do { cout<<"Enter the stock price and the number of shares.\n"; cout<<"Enter the price and integers: Dollars, numerator, denominator\n"; cin>>dollars>>numerator>>denominator; cout<<"Enter the number of shares held\n"; cin>>shares; cout<<shares; price1 = price(dollars,numerator,denominator); cout<<" shares of stock with market price of "; cout<< dollars << " " << numerator<<'/'<<denominator<<endl; cout<<"have a value of " << shares * price1<<endl; cout<<"Enter either Y/y to continue"; cin>>ans; }while (ans == 'Y' || ans == 'y'); system("pause"); return 0; } int price(int dollars, int numerator, int denominator) { return dollars + numerator/static_cast<double>(denominator); }

    Read the article

  • Collection was modified; enumeration operation may not execute

    - by Rita
    I have the below code. I am trying to remove the record and it is throwing Exception when it is removing the Record. "Collection was modified; enumeration operation may not execute." Any ideas on how to get rid of the message. Appreciate your time. //validClaimControlNo has valid ClaimControl Numbers. List<string> validClaimControlNo = new List<string>(); int count = 0; foreach (List<Field> f in records) { foreach (Field fe in f) { if (i == 0) if (!(validClaimControlNo.Contains(fe.Value))) { //if this claim is not in the Valid list, Remove that Record records.RemoveAt(count); } i++; } i = 0; count++; }

    Read the article

  • sql server - how to execute tje second half of or only when first one fails

    - by fn79
    Suppose I have a table with following records value text company/about about Us company company company/contactus company contact I have a very simple query in sql server as below. I am having problem with the 'or' condition. In below query, I am trying to find text for value 'company/about'. If it is not found, then only I want to run the other side of 'or'. The below query returns two records as below value text company/about about Us company company Query select * from tbl where value='company/about' or value=substring('company/about',0,charindex('/','company/about')) How can I modify the query so the result set looks like value text company/about about Us

    Read the article

  • How to create a bash function with variable parameters/arguments to grep several keywords/tags

    - by CornSmith
    I'm using the :!grep "tag1" filename | grep "tag2" filename | grep -n "tag3 or more" filename command in vim to search for my code snippets based on their tags (a simple comment at the top of a snippet) in one big file. I use snippets to remember tricky things. This is painful to write out each time. I'd like to make an alias, or function to do something like this: :!greptag tag1 tag2 ... tag39 And it should search the current doc and return the lines with all the tags on them. Vim is set to interactive shell mode so that it can parse my bashrc for aliases/functions. set shellcmdflag=-ic How can I construct a function that allows for variable arguments like this in bash?

    Read the article

  • Android: Width and Height of View After Orientation Change

    - by David
    I need to get the width and height of a WebView and pass them in the query string of the URL I am loading in the WebView. I have found a way to do this in onResume(). Since the width and height are not calculated at this point, I post a Runnable to the WebView to be queued for after the UI loads. Here's my problem: when the orientation changes, I am handling it in onConfigurationChanged. When I try to post a Runnable in onConfigurationChanged to the WebView, the WebView's width and height end up being the old orientation's width and height. At what point can I intercept the new width and height after orientation change?

    Read the article

  • No route matches [PUT] error in active_admin

    - by Alex
    in active_admin partials created a form input: <%= semantic_nested_form_for @item, :url => admin_items_path(@item) do |f| %> <fieldset class="inputs"> <ol> <%= f.input :category %></br> <%= f.input :title %> <%= f.input :photo1 %> <%= f.input :photo2 %> </ol> </fieldset> <%= f.fields_for :ItemColors do |i| %> <fieldset class="inputs"> <ol> <%= i.input :DetailColor %> <%= i.input :size, :input_html => { :size => "10" } %> <%= i.link_to_remove "remove" %> </ol> </fieldset> <% end %> <%= f.link_to_add "add", :ItemColors %> <%= f.actions %> <% end %> to create a new Item okay creates and throws On the New Item, but if I do update an existing item is routed to an error occurs while such a path exists: No route matches [PUT] "/admin/items.150" #150 is item_id rake routes: batch_action_admin_items POST /admin/items/batch_action(.:format) admin/items#batch_action admin_items GET /admin/items(.:format) admin/items#index POST /admin/items(.:format) admin/items#create new_admin_item GET /admin/items/new(.:format) admin/items#new edit_admin_item GET /admin/items/:id/edit(.:format) admin/items#edit admin_item GET /admin/items/:id(.:format) admin/items#show PUT /admin/items/:id(.:format) admin/items#update DELETE /admin/items/:id(.:format) admin/items#destroy help to solve this problem UPD I found the error, but not yet understood how to fix it the upgrade is a request: PUT "/admin/items" but should: PUT "/admin/items/some_id" any ideas?

    Read the article

  • Resize a DIV when its text changes

    - by Antonios
    I wanted to build a custom html button without using any solution like bootstrap etc. but from scratch. I decided to use a div to build my button with very good results. However, when the text changes its length that does not mean the div will change its width as well. Should I approach this using javascript or is there a CSS solution I am missing. Apologies for missing code: div { position: relative; width: 121px; height: 30px; } I need a minimum width and not a dynamic this is why I used a fixed one. In case there is not a CSS alternative then I will use a javascript approach.

    Read the article

  • Letting user carry on after three attempts

    - by sMilbz
    In my spelling game there is a grid that is populated with words. The words are hidden and the aim of the game is to spell the word that is highlighted with the aid of a sound and a picture. To highlight a word you press the "next" button. At the moment if you spell the word correctly it says "well done" and you can advance to the next word, but if you spell it incorrectly you have to keep attempting the word until it is complete. As the game is designed for children I do not think this is the best approach, so I would like to make it so you can advance after 3 incorrect attempts. I have played around with the script so much trying to put counters on incorrect attempts and then making the button active but cannot seem to get it to work. Can someone please help me? Here is the script for the button var noExist = $('td[data-word=' + listOfWords[rndWord].name + ']').hasClass('wordglow2'); if (noExist) { $('.minibutton').click(); } else { $('.minibutton').click('disable'); $("#mysoundclip").attr('src', listOfWords[rndWord].audio); audio.play(); $("#mypic").attr('src', listOfWords[rndWord].pic); pic.show(); } }); "wordglow2" is the style applied if the word is spelt correctly. Here is a fiddle to help understand... http://jsfiddle.net/smilburn/ZAfVZ/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

  • rc.local on ubuntu on ec2 will not work

    - by Tampa
    Below are the contents of my rc.local file. When I run sudo /etc/rc.local it works fine. When I boot up and instance. I expect monit to be installed but it is not. I am at a total loss. I usually use rc.local but this is rather confunsing. #!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. apt-get -y install monit /etc/init.d/monit stop cd /home/ubuntu/workspace/rtbopsConfig/ git fetch git checkout origin/master rtb_ec2_boot/ec2_boot.py git checkout origin/master config/ cp /home/ubuntu/workspace/rtbopsConfig/config/monit/redis/monitrc /etc/monit/ /usr/bin/python /home/ubuntu/workspace/rtbopsConfig/rtb_ec2_boot/ec2_boot.py >> /home/ubuntu/workspace/ec2_boot.txt 2>&1 /etc/init.d/monit start chkconfig monit on exit 0

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16  | Next Page >