PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0
Showing posts with label header. Show all posts
Showing posts with label header. Show all posts

Tuesday, November 8, 2022

[FIXED] How do I get a menu to go on top of everything?

 November 08, 2022     css, header, html, javascript, menu     No comments   

Issue

I am trying to have a menu that takes up 100vh when the menu button is clicked. However, I also have a header at the top so the menu content is lower than it. How do I make the menu go on top of the header? I'm trying to do this without making the header display: none because I want it to be shown on the side - in the left over space from making the menu have a view width of 80vw.

header {
  height: 3.4rem;
  display: grid;
  align-items: center;
  z-index: 1;
}

.menu {
  z-index: 2;
  position: relative;
  background-color: #000;
  margin-left: 4rem;
}

.menu-container {
  width: 80vw;
  height: 100vh;
  margin-left: 2.5rem;
  margin-top: 2rem;
}
<header>
  <div class="header-container">
    <div class="left">
      <img src="img/logo.jpg" alt="">
    </div>
    <div class="right">
      <img src="img/user.png" alt="">
      <i class="fa-solid fa-bars fa-xl"></i>
    </div>
  </div>
</header>
<nav class="menu">
  <div class="menu-container">
    <div class="top-menu">
      <a href="">Premium</a>
      <a href="">Support</a>
      <a href="">Download</a>
      <div class="menu-line"></div>
    </div>
    <div class="bottom-menu">
      <a href="">Account</a>
      <a href="">Log out</a>
    </div>
    <img src="img/logo.jpg" alt="">
  </div>
</nav>
(I did not add all the CSS to do with the menu and header because the rest of it is irrelevant.)

How do I move the menu to go on top?


Solution

I think position: relative is not set properly, it should only be on a parent that contains both header and nav. And then set the following css :

.menu {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 80vw;
}

Add margin and background if you want.

Now nav should be above header.



Answered By - paulin-crtn
Answer Checked By - Clifford M. (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] Why is there a gap between the header and the main div?

 November 08, 2022     css, header, html, menu, nav     No comments   

Issue

There is a gap between the header and the main that is the same color as the background color I set for the body tag (black). I've tried making overflow: hidden and margin: 0 but that did not work either.

What is causing this gap?

(.menu does not show if the menu button has not been clicked - so display: none)

body {
  color: #fff;
  font-family: Gotham;
  font-weight: 400;
  background-color: #000;
  margin: 0;
  padding: 0;
  max-width: 100%;
  overflow-x: hidden;
}

main {
  margin: 0;
  padding: 0;
  overflow: hidden;
}

header {
  height: 3.4rem;
  display: grid;
  align-items: center;
  overflow: hidden;
}

.menu {
  display: none;
  overflow-x: none;
  margin-top: 0;
}

.top {
  background-color: var(--purple);
  top: 0;
  margin: 0;
  padding: 0;
}

.top-container {
    margin: 2rem 1rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
<header>
  <div class="header-container">
    <div class="left">
      <img src="img/logo.jpg" alt="">
    </div>
    <div class="right">
      <img src="img/user.png" alt="">
      <i class="fa-solid fa-bars fa-xl"></i>
    </div>
  </div>
</header>
<nav class="menu">
  <div class="menu-container">
    <!-- content -->
  </div>
</nav>
<main>
  <section class="top">
    <div class="top-container">
      <!-- content -->
    </div>
  </section>
</main>

How do I get rid of the gap?


Solution

It turns out that all I needed to do was make the top-container margin-top: 0. The margin for the top and bottom before was at 2rem.

So it looked like:

.top-container {
    margin: 0rem 1rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

So to add space between the top of the container and the content, you need to add margin to the actual content not the container.



Answered By - tices
Answer Checked By - David Goodson (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Monday, October 31, 2022

[FIXED] Why is the browser not caching my images?

 October 31, 2022     caching, header     No comments   

Issue

I am using nginx and Adaptive Images to deliver dynamically sized images based on device resolution. The response headers being set by the adaptive-images.php file are shown below but every time I refresh the page the browser requests the images again. Why is the browser not caching these images? The browser is Google Chrome and it seems to be setting max-age=0 in the request headers no matter how I refresh. I've tried F5, Ctrl+F5 and entering the URL in the address bar and hitting Enter.

Request Headers:

GET /img/photos/p8.jpg HTTP/1.1
Host: example.com
Connection: keep-alive
Cache-Control: max-age=0
Accept: image/webp,*/*;q=0.8
Pragma: no-cache
If-Modified-Since: Wed, 16 Jul 2014 12:01:31 GMT
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36
Referer: http://example.com/
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8,en-GB;q=0.6

Response Headers:

HTTP/1.1 200 OK
Server: nginx
Date: Wed, 16 Jul 2014 12:08:55 GMT
Content-Type: image/jpeg
Content-Length: 391104
X-Powered-By: PHP/5.4.30
Cache-Control: private, max-age=604800
Expires: Wed, 23 Jul 2014 12:08:55 GMT
Last-Modified: Wed, 16 Jul 2014 12:08:55 GMT
Connection: Keep-Alive

Solution

It turns out that this seems to be a Chrome feature

See this other SO answer for why: Chrome doesn't cache images/js/css



Answered By - conorgriffin
Answer Checked By - Willingham (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How can I achieve this kind of box-styling in CSS

 October 31, 2022     border-radius, css, header, html     No comments   

Issue

I just came across a website where almost all the div were styled that way, and I would be interested to know how it is done.

enter image description here


Solution

You can easily get the orange shape by using the clip-path property. I used a Generator to make this shape.

p {
            margin: 0;
        }

        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }

        .card {
            width: 300px;
            background-color: #1D1D1D;
            border-radius: 20px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
        }

        .heading {
            font-size: 18px;
            text-transform: uppercase;
            color: white;

        }

        .orange {
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            border-radius: 20px;
            width: 100%;
            height: 100px;
            margin-top: 0;
            background-color: #FB961B;
            clip-path: polygon(0 0, 100% 0, 100% 50%, 60% 100%, 40% 100%, 0% 50%);
        }

        .container {
            margin: 10px 20px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
        }
        p{
            color: white;
        }
        #heading{
            font-size: 18px;
            text-transform: uppercase;
        }

        .para{
            margin-bottom: 20px;
        }
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div class="card">
        <div class="orange">
            <p class="heading">starter</p>
            <p class="para">weekly 100% for 4 times</p>
        </div>
        <div class="container">
            <p id="heading">weekly return</p>
            <p>Lorem ipsum... </p>
        </div>
    </div>
</body>

</html>



Answered By - Lemirq
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] What is the common header format of Python files?

 October 31, 2022     comments, header, python     No comments   

Issue

I came across the following header format for Python source files in a document about Python coding guidelines:

#!/usr/bin/env python

"""Foobar.py: Description of what foobar does."""

__author__      = "Barack Obama"
__copyright__   = "Copyright 2009, Planet Earth"

Is this the standard format of headers in the Python world? What other fields/information can I put in the header? Python gurus share your guidelines for good Python source headers :-)


Solution

Its all metadata for the Foobar module.

The first one is the docstring of the module, that is already explained in Peter's answer.

How do I organize my modules (source files)? (Archive)

The first line of each file shoud be #!/usr/bin/env python. This makes it possible to run the file as a script invoking the interpreter implicitly, e.g. in a CGI context.

Next should be the docstring with a description. If the description is long, the first line should be a short summary that makes sense on its own, separated from the rest by a newline.

All code, including import statements, should follow the docstring. Otherwise, the docstring will not be recognized by the interpreter, and you will not have access to it in interactive sessions (i.e. through obj.__doc__) or when generating documentation with automated tools.

Import built-in modules first, followed by third-party modules, followed by any changes to the path and your own modules. Especially, additions to the path and names of your modules are likely to change rapidly: keeping them in one place makes them easier to find.

Next should be authorship information. This information should follow this format:

__author__ = "Rob Knight, Gavin Huttley, and Peter Maxwell"
__copyright__ = "Copyright 2007, The Cogent Project"
__credits__ = ["Rob Knight", "Peter Maxwell", "Gavin Huttley",
                    "Matthew Wakefield"]
__license__ = "GPL"
__version__ = "1.0.1"
__maintainer__ = "Rob Knight"
__email__ = "rob@spot.colorado.edu"
__status__ = "Production"

Status should typically be one of "Prototype", "Development", or "Production". __maintainer__ should be the person who will fix bugs and make improvements if imported. __credits__ differs from __author__ in that __credits__ includes people who reported bug fixes, made suggestions, etc. but did not actually write the code.

Here you have more information, listing __author__, __authors__, __contact__, __copyright__, __license__, __deprecated__, __date__ and __version__ as recognized metadata.



Answered By - Esteban Küber
Answer Checked By - Timothy Miller (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How to create include files in Lua language?

 October 31, 2022     header, lua, require     No comments   

Issue

I want to create a header file in Lua (header.lua), then execute the require function to load it.

How do I execute require to a file that I have created?


Solution

require "header"

See the require entry in the Lua Reference manual. The file "header.lua" must be somewhere in Lua's search path.

You can see (and modify) the path at

package.path

See the package.path entry in the the Lua Reference Manual

This wiki page describes ways of creating modules to load with require.



Answered By - Doug Currie
Answer Checked By - Clifford M. (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How can I use g++ to get assembly code for a C++ header (.hpp) file?

 October 31, 2022     assembly, c++, header     No comments   

Issue

I'm interested in trying to see the assembly code for my header file. Playing around with a simple .cpp file with a dummy main method and compiling it is easy: g++ -S -o prog.exe main.cpp

However, I'm going into header files now. I have a dummy header file func.hpp that just contains a dummy method and now I want to be able to compile it and see its assembly in a .S file. (The main reason for this is so that if I have a more complicated function, maybe I can do some manual optimization in assembly and just build the final executable through g++ -o prog.exe func.S main.cpp.

However, I am not able to find sources that explain this. If I try g++ -S -o func.S func.hpp I get an error message output filename specified twice. Can anyone help me with this?

For reference, here is func.hpp:

int number()
{
    return 0;
}

I'm also trying it out with another hpp file named struct.hpp:

struct Coord
{
    int x;
    int y;
};

Same error for both, but I want to be able to see the assembly for both headers without converting them to .cpp files (because that breaks the meaning of a header file.)


Solution

You could force g++ to treat the .hpp file as a C++ source file.

g++ -x c++ -S -o func.S func.hpp

The reason you get that "output filename specified twice" message is because, when passing a header file to gcc, it will assume you want to compile it into a pre-compiled header. Just as named, this will "compile" the headers, so a *.s file will be generated in the middle. If you pass the -v flag with the original command, you will see that cc1plus is called like:

 /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.1/cc1plus
     -quiet
     -v 
     -D_GNU_SOURCE 
     func.hpp
     -quiet 
     -dumpbase func.hpp 
     -mtune=generic 
     -march=x86-64 
     -auxbase-strip func.S
     -version 
     -o func.S                # <---
     -o /tmp/ccxEg3J7.s       # <---
     --output-pch= func.S

So indeed -o is specified twice, once from your -o and once from the compiler.

(Of course the compiler could avoid adding the -o /tmp/ccxEg3J7.s, but the added complexity for this edge case isn't quite worth it.)



Answered By - kennytm
Answer Checked By - Clifford M. (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How to increase header size limit Tomcat Java

 October 31, 2022     header, http, java, tomcat     No comments   

Issue

Looking at https://tomcat.apache.org/tomcat-9.0-doc/config/http.html I see that 8KB is the default limit of Header Size in Tomcat Apache.

The log shows the following when I make a request with headers more than the default 8KB: Dec 30, 2019 1:59:26 PM org.apache.coyote.http11.Http11Processor service INFO: Error parsing HTTP request header Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level. java.lang.IllegalArgumentException: Request header is too large at org.apache.coyote.http11.Http11InputBuffer.fill(Http11InputBuffer.java:720) at org.apache.coyote.http11.Http11InputBuffer.parseHeader(Http11InputBuffer.java:867) at org.apache.coyote.http11.Http11InputBuffer.parseHeaders(Http11InputBuffer.java:563) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:311) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:836) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1839) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748)

My Java Project does not have a server.xml inside /webapp/WEB-INF, just the web.xml. I tried to create a server.xml and add the following like said in this thread: <?xml version='1.0' encoding='utf-8'?> <Connector port="8080" protocol="HTTP/1.1" maxHttpHeaderSize="65536" maxPostSize="4194304" URIEncoding="UTF-8"/>//webapp/WEB-INF

How Can I increase the default size limit? I'd like to set 16KB.

Thanks in advance =)

PS: I am new in Tomcat/Java World, so sorry if I made a horrible mistake =p


Solution

Looking at API doc seems that this one

Tomcat t = new Tomcat();
t.getConnector().setAttribute("maxHttpHeaderSize",65536);

could be a valid solution.



Answered By - Renato
Answer Checked By - Mildred Charles (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How to corectly set the ContentType property in HttpWebRequest (or how to fix the missing Content-Type header)

 October 31, 2022     content-type, contenttype, header, httpwebrequest     No comments   

Issue

I thought I'd share something that took me some time to figure out:

I wrote a simple Post method using HttpWebRequest class. In HttpWebRequest you can't use HttpWebRequest.Headers collection to set your desired headers when there is a dedicated property for it - you must use that dedicated property. ContentType is one of them. So I created my HttpWebRequest like this:

            HttpWebRequest httpWebRequest = (HttpWebRequest)webRequest;
            httpWebRequest.Method = "POST";
            httpWebRequest.KeepAlive = false;
            httpWebRequest.ServicePoint.Expect100Continue = false;
            httpWebRequest.ContentType = "application/json";

somewhere below I set the body of my request like this:

            using (StreamWriter streamWriter = new StreamWriter(streamWebRequest))
            {
                streamWriter.Write(sJson);
            }

and posted the request using:

            WebResponse webResponse = httpWebRequest.GetResponse();

But I kept getting a "400 - Bad Request" error, while the same request worked from Postman. After analyzing the request with Fiddler I found that when I send the request from my app, the Content-Type: application/json header is missing. All the other headers were present, except for Content-Type. I thought I'm setting it wrong, so I googled but didn't find a good answer. After much experimentation I found, that if I move the line:

            httpWebRequest.ContentType = "application/json"

after this block:

            using (StreamWriter streamWriter = new StreamWriter(streamWebRequest))
            {
                streamWriter.Write(sJson);
            }

then the httpWebRequest.ContentType = "application/json" header finally appears in the request. So, for HttpWebRequest make sure you always set your HttpWebRequest's body/content first, before you set the ContentType property.

Hope it helps


Solution

My question above already has the answer, but to mark it as "Answered" I had to add this comment:

Make sure you always set your HttpWebRequest's body/content first, before you set the ContentType property.This way the "Content-Type" header will appear in the request.



Answered By - Alexey Nagoga
Answer Checked By - Terry (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] What happens if I implement a class in the header file?

 October 31, 2022     c++, header     No comments   

Issue

Possible Duplicate:
Inline functions in C++

What does the compiler do if I completely implement a class in its header file? A typical example follows:

class MyException
{    
public:
    explicit MyException(const char* file, int line) file(file), line(line) {};
    const char* getFile() const { return file };
    int getLine() const { return line };
private:
    const char* const file;
    const int line;
};

My intention is to use the class like this: throw MyException(__FILE__, __LINE__).

I include this header file into each .cpp file. I suppose the compiler will compile the class as many times as it is defined and include the (identical) machine code into every object file it produces. Now, what will the linker do? I tried a simpler example (without all those pesky const's) and it compiled fine.

What would happen, if instead of a simple class, I implemented a three-screenful-long C function in a header file? And the final question, should I split my example into .h and .cpp files?


Solution

A class definition itself doesn't produce any code. It just shows users of the class how it is layed out, so they can generate appropriate code to manipulate it.

It's the member functions of the class that generate code. When you define a member function inside the class definition it gives the function an implicit inline declaration.

A function call can be compiled and linked in one of two ways:

(1) A single copy of the function code with a RETURN assembly instruction at the end can be placed in the image, and a CALL assembly instruction can be placed (along with param passing and return value transfer) at the call site to transfer control to this code.

or

(2) An entire copy of the function implementation can replace the entire function call at the call site.

A function declared inline is a recommendation to the compiler to do it the second way. Further an inline declaration allows the function to be defined in several translation units (so it can be placed in a shared header file). In order for the compiler have the option of implementing the second method, it needs a copy of the function implementation at compile-time. This isn't available if the function implementation is in a foreign translation unit.

It should also be noted that modern compilers do complicated things with functions declared inline. See:

http://gcc.gnu.org/onlinedocs/gcc/Inline.html



Answered By - Andrew Tomazos
Answer Checked By - Timothy Miller (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Friday, October 28, 2022

[FIXED] How to get GridView.ShowHeaderWhenEmpty Property to display headers

 October 28, 2022     asp.net-4.6, aspxgridview, c#, header, is-empty     No comments   

Issue

I am using .NET Framework 4.6.1 in my Asp.Net application and trying to apply the GridView.ShowHeaderWhenEmpty property to my gridview to display the headers on page load (before the data table has data fill in the rows and is empty). When I load this page, there is just a blank space until the user clicks some other controls.

ASPX

 <div class="col-md-12" style="overflow: auto; width: 1150px; max-height: 800px; height: 800px; border-style:solid; border-color: darkblue; border-width:thin;">
   <asp:GridView ID="uxSearchGridView" runat="server" ShowHeaderWhenEmpty="true" CssClass="GridView"  HeaderStyle-BackColor="#ADD8E6" BorderStyle="Solid" onRowDataBound="uxSearchGridView_RowDataBound" AutoGenerateColumns="False" OnSorting="uxSearchGridView_Sorting" BackColor="White" BorderColor="#D6D2D2" BorderWidth="1px" CellPadding="3" SelectedIndex="-1" DataKeyNames="TicketNumber" AllowSorting="True" Font-Size="Small" Width="100%" Visible="True" EnableModelValidation="True" style=" margin-top: 10px; margin-bottom: 10px;">
       <Columns>
         <asp:CommandField ShowSelectButton="True" SelectText="Details" ButtonType="Button" HeaderText="Select" />
         <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" />
         <asp:BoundField DataField="TicketNumber" HeaderText="Ticket Number" SortExpression="Ticket Number" />
         <asp:BoundField DataField="Complexity" HeaderText="Complexity" SortExpression="Complexity" />
         <asp:BoundField DataField="NatureOfInquiry" HeaderText="Nature of Inquiry" SortExpression="NatureOfInquiry" />
         <asp:BoundField DataField="SMEResponseDetail" HeaderText="Response" SortExpression="SMEResponseDetail" />
       </Columns> 
       <FooterStyle BackColor="White" ForeColor="#000066" />
       <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
       <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
       <RowStyle ForeColor="#000066" />
       <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
       <SortedAscendingCellStyle BackColor="#F1F1F1" />
       <SortedAscendingHeaderStyle BackColor="#007DBB" />
       <SortedDescendingCellStyle BackColor="#CAC9C9" />
       <SortedDescendingHeaderStyle BackColor="#00547E" />
   </asp:GridView>
 </div>

C#

  protected void Page_Load(object sender, EventArgs e)
  {
        _dtMgr = new DataAccessManager()
        string staffName = _dtMgr.GetStaffNameByUser(Session["UserNameSession"].ToString());
        if (staffName == string.Empty)
        {
            //error
        }
        else
        {
            Session["StaffName"] = staffName;
            if (!Page.IsPostBack)
            {
                uxSearchGridView.DataSource = null;
                uxSearchGridView.DataBind();
            }
        }
    }

Is there something I'm leaving out or is there another reason that my headers will not display on page load?


Solution

I finally realized that I had to create an empty data table and bind it in order for ShowHeaderWhenEmpty to work. On page load, I added null parameters (that allowed null parameters) to my sp that would return the dataset I would eventually use as the Datasource for my gridview. This returned an empty table but allowed the headers display. I also added and empty row (just for aesthetic purposes):

protected void Page_Load(object sender, EventArgs e)
{
  _searchDT = _dtMgr.GetTicketsByKeyword(uxKeywordTextBox.Text, null);
      ....
      if (!Page.IsPostBack)
            {
                DataRow dr = null;
                dr = _searchDT.NewRow();
                _searchDT.Rows.Add();
                uxSearchGridView.DataSource = _searchDT;
                uxSearchGridView.DataBind();
            }
        }
     ...
}


Answered By - gwydion93
Answer Checked By - David Goodson (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Monday, October 24, 2022

[FIXED] How do I add a margin to the left of the logo in a WP header

 October 24, 2022     css, header, wordpress     No comments   

Issue

I am using the Ashe theme on Wordpress, which places the logo on the header image of the site in the middle. I managed to move the logo to the left of the header, but it has no margin, so the edge of the logo is right on the edge of the site. I want to add a 15px margin to the left of the logo, but nothing seems to work.

I have the following additional css added:

$custom_logo_defaults img{float:left;margin-top:20%;margin-left:15px}

$custom_logo_defaults .site-title{margin-top:2%;margin-left:15px}

I have also tried changing the php code in the style sheets, but that also doesn’t seem to have any effect.


Solution

The code you have provided will not work as is. You need to add the correct CSS selectors.

The correct CSS would be:

.custom-logo-defaults img {
    float: left;
    margin-top: 20%;
    margin-left: 15px;
}

__

.custom-logo-defaults .site-title {
    margin-top: 2%;
    margin-left: 15px;
}


Answered By - Mohamed Elgazar
Answer Checked By - Robin (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Wednesday, October 5, 2022

[FIXED] When to run `headers` while using a btn connected to ajax

 October 05, 2022     ajax, header, javascript, php, phpexcel     No comments   

Issue

I have a button created with HTML.
The button calls a Jquery function on('click')
Now, ajax is triggered to fetch data from PHP.
The PHP script should output a excel file and open a save dialog for the user to download the excel file.

So i have three files: Main PHP, JS and back-end PHP.
If i put the headers in Main PHP, the save dialog appears just as i enter the page. (Not when pressing button)
If i put the headers first off in the "back-end PHP" nothing hapends at all.

So, where should i put the "headers"?
Maby i cannot do it this way?

HEADERS

header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header("Content-Disposition: attachment; filename=\"file.xlsx\"");
header("Cache-Control: max-age=0");

HTML Button in Main PHP

<button class="btn btn-default" id="btnExportElementdata"><span class="glyphicon glyphicon-save" title="Spara"></span></button>

JS

//Btn Save
$('#btnExportElementdata').on('click', function(){
    //Fetch selected ObjNr
    objNr = $('#selectObjekt').val();
    //Send objNr to php and fetch elementData
    $.ajax({
        url: '../phpexcel/php/exportElementData.php',
        method: 'POST',
        data: {objNr : objNr},
        success: function(result){
            $('#elementData').append(result);
        }
    })       
})

Back-End PHP

<?php
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header("Content-Disposition: attachment; filename=\"results.xlsx\"");
header("Cache-Control: max-age=0");

//Load db connection
require("conf.php");
//Check if usr is logged in
if(empty($_SESSION['user'])){
  header("Location: index.php");
  die("Redirecting to index.php"); 
}

//Check IF post
if(!empty($_POST['objNr'])){
  //Store post in var
  $objNr = $_POST['objNr'];


  /** Error reporting */
  error_reporting(E_ALL);

  //Load phpexcel includes    
  require '../Classes/PHPExcel.php';

  /** PHPExcel_Writer_Excel2007 */
  include '../Classes/PHPExcel/Writer/Excel2007.php';

  // Create new PHPExcel object
  $objPHPExcel = new PHPExcel();

  // Set properties
  $objPHPExcel->getProperties()->setCreator("Maarten Balliauw");
  $objPHPExcel->getProperties()->setLastModifiedBy("Maarten Balliauw");
  $objPHPExcel->getProperties()->setTitle("Office 2007 XLSX Test Document");
  $objPHPExcel->getProperties()->setSubject("Office 2007 XLSX Test Document");
  $objPHPExcel->getProperties()->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.");


  // Add some data
  $objPHPExcel->setActiveSheetIndex(0);
  $objPHPExcel->getActiveSheet()->SetCellValue('A1', 'Nr');
  $objPHPExcel->getActiveSheet()->SetCellValue('B1', 'Höjd');
  $objPHPExcel->getActiveSheet()->SetCellValue('C1', 'Typ');
  $objPHPExcel->getActiveSheet()->SetCellValue('D1', 'Längd');
  $objPHPExcel->getActiveSheet()->SetCellValue('E1', 'AV');
  $objPHPExcel->getActiveSheet()->SetCellValue('F1', 'Öppningar');

  $objPHPExcel->getActiveSheet()->SetCellValue('G1', 'Vikt');


  //Fetch data from DB
  $query = "SELECT * FROM element WHERE objekt_nr = '$objNr' ORDER BY length(element_nr), element_nr ASC";
  try{
    $stmt = $db->prepare($query);
    $result = $stmt->execute();
  }
  catch(PDOException $ex){
    die("Failed to run query: " . $ex->getMessage());
  }
  //Insert on first row after heading 
  $row = 2;
  while($value = $stmt->fetch()){
    //Set start Column
    $column = "A";

    $objPHPExcel->getActiveSheet()->SetCellValue($column++.$row, $value['element_nr']);
    $objPHPExcel->getActiveSheet()->SetCellValue($column++.$row, $value['hojd']);
    $objPHPExcel->getActiveSheet()->SetCellValue($column++.$row, $value['typ']);
    $objPHPExcel->getActiveSheet()->SetCellValue($column++.$row, $value['langd']);
    $objPHPExcel->getActiveSheet()->SetCellValue($column++.$row, $value['avdrag']."");
    $objPHPExcel->getActiveSheet()->SetCellValue($column++.$row, $value['oppningar']."");

    $objPHPExcel->getActiveSheet()->SetCellValue($column++.$row, $value['vikt']);

    //INCREASE Row Nr
    $row++;
}

// Rename sheet
$objPHPExcel->getActiveSheet()->setTitle($objNr);

// Write file to the browser
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
$objWriter->save('file.xlsx');

}
else{
  echo 'Välj objektnummer..';
}

All script but save dialog works just fine!
If i Save the file on server it works perfect.
This issue is all about headers!


Solution

You need to remove those headers from the files.

You can use ajax if you want but you must return only the link where the file resides and show it in the browser. When the user click on this link a function will be called. You will set the headers in this function which will force the saved file to be downloaded. I hope this will make sense to you.



Answered By - Franco
Answer Checked By - David Goodson (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Wednesday, September 21, 2022

[FIXED] How to change content-type but keep charset on Apache2?

 September 21, 2022     apache, apache2, content-type, header, virtualhost     No comments   

Issue

I have a Apache2 server on Ubuntu for proxy server. I want to change content-type of response to client to another but it will remove charset too.

# /etc/apache2/sites-available/000-default.conf
Header set Content-Type "text/html" "expr=%{resp:Content-Type} =~ m|text/abcdefgh|"  

With this setting, when it see the header which content-type is text/abcdefgh or text/abcdefgh; charset=utf-8 or text/abcdefgh; charset=shift_jis, it will become text/html without charset

  1. Is there any way to change part of content-type by Header set or others?
  2. Where can I find the meaning of this pattern?

Many thanks!


Solution

Did you try to use edit instead of set?

Header edit Content-Type "text/abcdefgh" "text/html"

It should just replace text/abcdefgh with text/html but leave the charset as is



Answered By - Capsule
Answer Checked By - Willingham (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Sunday, August 28, 2022

[FIXED] How to Check CSV file headers for specific word in Python

 August 28, 2022     cell, csv, header, if-statement, python-3.x     No comments   

Issue

I have several CSV files and their headers are similar for the first 10 columns and then they are different. So I need to check each of the CSV files and see if in the column 11 they have word ABC or XYZ or SOS so then I can apply my other function on each CSV depending on the header. Can anyone please help me with the if conditions that I need to apply to read the headers and compare column 11 in header with the strings I mentioned?


Solution

I'd use glob to loop for each csv, and pandas to read the columns names.

import glob

path = r"*.csv"  # The path to the folder containing your csv files

for file_name in glob.glob(path):  # Looping through the list of paths 
    df = pd.read_csv(file_name)

    list_of_column_names = list(df.columns)  # Getting the headers of your dataframe

    if 'ABC' in str(list_of_column_names[11]):
        print('ABC case')
    elif 'XYZ' in str(list_of_column_names[11]):
        print('XYZ case')
    elif 'SOS' in str(list_of_column_names[11]):
        print('SOS case')
    else:
        print('Other Case')


Answered By - Guillaume
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Friday, July 1, 2022

[FIXED] How to move my header-logo above the menu items?

 July 01, 2022     css, header, html, mobile, shopify     No comments   

Issue

I am trying to optimize my shopify store for mobile. But I ran in an issue that I can't fix. My mobile version looks like this right now: see mobile version here

I would like to make the logo bigger, but yet I need the other icons displayed aswell. I was wondering if there is a possibility to move the logo to a line above the other icons in mobile version. So my mobile header would have two lines; on the first is the logo and on the second all the other icons. This would look somehting like this: see wish verison of mobile here

My store url is: snow-pearl.com and I am using the debut shopify theme. You can find the header.liquid code by clicking here.

If this isn't possible only for the mobile version, is it possible to implement in the desktop and mobile version? It doesn't matter if the logo is a line above everything else in the desktop version aswell.

Any help or ideas are greatly appreciated. Thanks so much!

If you need to know anything more, don't hesitate to ask.


Solution

You need to add this CSS to make your block to switch to column.

-webkit-flex-direction:column;
flex-direction: column;

Flex-direction documentation

On this existing CSS:

@media only screen and (max-width: 749px){
  .site-header__mobile-nav{
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    width: 100%;
    -ms-flex-align: center;
    -webkit-align-items: center;
    -moz-align-items: center;
    -ms-align-items: center;
    -o-align-items: center;
    align-items: center;
  }
}

After that you will need to fix the width of your blocks.



Answered By - MaxiGui
Answer Checked By - Mildred Charles (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How to change entire header on scroll

 July 01, 2022     header, onscroll, shopify     No comments   

Issue

I have a client that wants a header like on this site http://www.solewood.com/ I have found a few questions here but they are geared only for a certain element of the header. Here is the site I am working on http://treestyle.com/ The password is vewghu They are both shopify sites. Any help would be greatly appreciated.


Solution

If you inspect the solewoood website you can get an idea of how they've implemented the header.

When the page is at the top, there is this CSS for the header div:

<div class="header">

.header {
    position: fixed;
    transition: all 500ms ease 0s;
    width: 100%;
    z-index: 1000;
}

And when you scroll down, the .header_bar CSS class is added to the div as well:

<div class="header header_bar">

.header_bar {
    background-color: #FFFFFF;
    border-bottom: 1px solid #E5E5E5;
}

.header {
    position: fixed;
    transition: all 500ms ease 0s;
    width: 100%;
    z-index: 1000;
}

There are a few other things that are also changed when the user scrolls down from the top (logo, text colour, etc.), but you get the idea.

If you are unsure how to detect if the user is at the top of the page, see here.

EDIT:

In response to your comment, try using jQuery's .toggleClass() with 2 parameters.

For example:

$(window).scroll(function(e){
    $el = $('.header');
    $el.toggleClass('header_bar', $(this).scrollTop() > 0); 
}); 


Answered By - Steph Sharp
Answer Checked By - Katrina (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How to change entire header on scroll

 July 01, 2022     header, onscroll, shopify     No comments   

Issue

I have a client that wants a header like on this site http://www.solewood.com/ I have found a few questions here but they are geared only for a certain element of the header. Here is the site I am working on http://treestyle.com/ The password is vewghu They are both shopify sites. Any help would be greatly appreciated.


Solution

If you inspect the solewoood website you can get an idea of how they've implemented the header.

When the page is at the top, there is this CSS for the header div:

<div class="header">

.header {
    position: fixed;
    transition: all 500ms ease 0s;
    width: 100%;
    z-index: 1000;
}

And when you scroll down, the .header_bar CSS class is added to the div as well:

<div class="header header_bar">

.header_bar {
    background-color: #FFFFFF;
    border-bottom: 1px solid #E5E5E5;
}

.header {
    position: fixed;
    transition: all 500ms ease 0s;
    width: 100%;
    z-index: 1000;
}

There are a few other things that are also changed when the user scrolls down from the top (logo, text colour, etc.), but you get the idea.

If you are unsure how to detect if the user is at the top of the page, see here.

EDIT:

In response to your comment, try using jQuery's .toggleClass() with 2 parameters.

For example:

$(window).scroll(function(e){
    $el = $('.header');
    $el.toggleClass('header_bar', $(this).scrollTop() > 0); 
}); 


Answered By - Steph Sharp
Answer Checked By - Mary Flores (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Wednesday, May 18, 2022

[FIXED] How to search for partial matches in numbers using SlickGrid header row?

 May 18, 2022     header, match, partial, slickgrid     No comments   

Issue

I'm trying to perform partial matches in the header row example for SlickGrid.

I used the answer here: How to perform partial matches when filtering Slickgrid using column-level headers?

Which does do partial matches on text but will not do partial matches on numbers. Does anyone know how to do partial matches on both? Some of my columns have text and some have numbers and I want to be able to filter by each column.


Solution

Store your numbers as text in the grid data. Then this method should work for numbers as well. Same applies to boolean and dates as well.

If you want to keep using numbers though, you could check for the variable type in your filter using the typeof function and adding a new condition to handle number matches.



Answered By - ganeshk
Answer Checked By - Marie Seifert (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Saturday, March 12, 2022

[FIXED] Change status code in HTTP header without affecting return data in Yii 1 Restful API

 March 12, 2022     api, exception, header, php, yii     No comments   

Issue

I want to return data with the HTTP error code in Yii 1. So I used the following way to get the data.

  $code = (0 == $ex->getCode()) ? (isset($ex->statusCode) ? $ex->statusCode : 500) : $ex->getCode();
            $this->setOutputError($ex->getMessage());
            $this->setOutputCode($code);

When I use it this way API returns data with 200 error code as below enter image description here

But I want to change header status 200, so I threw exception for this, then output data also changed. I want to change only the header status.

$code = (0 == $ex->getCode()) ? (isset($ex->statusCode) ? $ex->statusCode : 500) : $ex->getCode();
            $this->setOutputError($ex->getMessage());
            $this->setOutputCode($code);

            throw new CHttpException(400, 'Bad Request');

enter image description here


Solution

Yii 1.1 does not have response abstraction, you need to use http_response_code() to change response status code:

$code = (0 == $ex->getCode()) ? (isset($ex->statusCode) ? $ex->statusCode : 500) : $ex->getCode();
$this->setOutputError($ex->getMessage());
$this->setOutputCode($code);

http_response_code(400);

Alternatively you may also use header(), but this is more tricky.



Answered By - rob006
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Older Posts Home

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
All Comments
Atom
All Comments

Copyright © PHPFixing